[BUG] invalid messages from static checker

Odpovědět [BUG] invalid messages from static checker

  • 5. dubna 2012 15:38
     
      Obsahuje kód

    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);
            }
        }
    }
    

Všechny reakce

  • 6. dubna 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?

  • 20. dubna 2012 17:30
    Vlastník
     
     Odpovědět

    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