[Issue 5906] Just pre-conditions at compile-time when arguments are static

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 7 19:25:18 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=5906



--- Comment #10 from bearophile_hugs at eml.cc 2013-03-07 19:25:12 PST ---
(In reply to comment #9)

> struct S(int a)
> {
>     void fun(int b) in { assert(a != b); } body {}
> }
> 
> void main()
> {
>     foreach(i; TypeTuple!(1, 2, 3, 4))
>     {
>         auto s = S!i();
>         if (i != 4)
>             s.fun(4);
>     }
> }
> 
> This code would error 'cannot call S.fun with b == 4' etc even though S.fun
> never actually gets called with 4.

I see, thank you for the answer.
If the pre-condition analysis (constant folding) is done after a normal step of
dead branch removal, then maybe that error will not be shown.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list