www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9169] New: semantic order difference in variable declaration

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: k.hara.pg gmail.com



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: -------
Dec 16 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9169




Related: issue 3131

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