Bug 9169 – semantic order difference in variable declaration

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-16T23:57:34Z
Last change time
2024-12-13T18:03:26Z
Assigned to
No Owner
Creator
Kenji Hara
Moved to GitHub: dmd#18506 →

Comments

Comment #0 by k.hara.pg — 2012-12-16T23:57:34Z
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).
Comment #1 by k.hara.pg — 2012-12-23T08:21:37Z
Related: issue 3131
Comment #2 by robert.schadek — 2024-12-13T18:03:26Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18506 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB