[Issue 9169] New: semantic order difference in variable declaration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 16 23:57:35 PST 2012


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

           Summary: semantic order difference in variable declaration
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2012-12-16 23:57:34 PST ---
Spin-off issue from bug 9159.

Between DeclDefs and function body scopes, semantic analysis works differently
for variable declaration.

----
version = A; // or B

struct P {
    int v;
    this(int i) { v = i; }
}

P p(int i) {
    assert(0);
    return typeof(return)(i);
}

class C {
  version(A)
    P p = p(10);    // Error: struct P does not overload ()
}

void main() {
  version(B)
    P p = p(10);    // asserts in runtime
}
----

In the semantic analysis for the expression p(10),
- `p` matches the declared variable itself in DeclDefs scope (version=A).
- `p` matches the module level function in function scope (version=B).

-- 
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