[BUG] invalid messages from static checker

Answered [BUG] invalid messages from static checker

  • jueves, 05 de abril de 2012 15:38
     
      Tiene código

    Following code produce five "message : CodeContracts: Suggested assumption: Assumption can be proven: Consider changing it into an assert." messages. Static checker options: Infer Ensures+Redundant Assumptions

    using System.Collections.Generic;
    using System.Diagnostics.Contracts;
    
    public class Bug
    {
        void F1()
        {
            F2(new List<object>());
        }
    
        void F2(List<object> list)
        {
            Contract.Requires(list != null);
    
            foreach (var item in list)
            {
                Contract.Assume(item != null);
            }
        }
    }
    

Todas las respuestas

  • viernes, 06 de abril de 2012 13:55
     
     

    That looks legit ... F2 is private and only invoked from F1, and that code path always supplies an empty list (hence no element is null).  What happens if you make F2 public?

  • viernes, 20 de abril de 2012 17:30
    Propietario
     
     Respondida

    Thank you for reporting it. The checker was proving some propagated postconditions (which at call site it sees as assumes).

    now it is (internally) fixed.

    ciao

    f