www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17491] New: Compiles on invalid: *&s.init.var is not an lvalue

https://issues.dlang.org/show_bug.cgi?id=17491

          Issue ID: 17491
           Summary: Compiles on invalid: *&s.init.var is not an lvalue
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

Test case:
---
struct S
{
  int i;
}

void bug()
{
   S.init = S(42);    // OK -> (S).init is not an lvalue
   *&S.init = S(42);  // OK -> S(0) is not an lvalue
   S.init.i = 42;     // OK -> constant S(0).i is not an lvalue
   *&S.init.i = 42;   // Compiles!
}
---

Having a look at the AST dump:

---
import object;
struct S
{
    int i;
}
void bug()
{
    0 = 42;  // <- This should be a compiler error.
}
RTInfo!(S)
enum typeof(null) RTInfo = null;
---

--
Jun 11