This project is read-only.
1

Closed

?? does not compile correctly

description

The ?? operator, inherited from C# and with the meaning "return the left-hand operand unless it is null; if it is null, return the right-hand operator", is not compiled correctly by the Spec# compiler. In particular, I found that (s.Tok.filename ?? ".dfy") compiles the str2 in:
    string str;
    string str2;
    if (str == null)
    {
        str2 = ".dfy";
    }
    else
    {
        str2 = str;
    }
Note that "str" is uninitialized. It should have been initialized to the left-hand operand of ??.
Closed Mar 5, 2011 at 11:48 AM by

comments

alexanderjsummers wrote Mar 5, 2011 at 11:47 AM

Fixed in revision 63112. The bug happened when the first operator was neither a local variable nor a parameter.