[Issue 19305] New: In symbol lookup, with statement becomes stronger than an inner scope import statement
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 13 04:48:24 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19305
Issue ID: 19305
Summary: In symbol lookup, with statement becomes stronger than
an inner scope import statement
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: shigekikarita at gmail.com
I found a breaking change of symbol from DMD2.073.0. I think this change comes
from a conflict between statement spec 4.3.2 and module spec 11.19.1.
see 4.3.2 in https://docarchives.dlang.io/v2.081.0/spec/module.html
see 11.19.1 in
https://docarchives.dlang.io/v2.081.0/spec/statement.html#with-statement
running example
https://wandbox.org/permlink/5bDsMZeqKYh4runs
-------
module a;
enum f = "a";
module b;
enum f = "b";
module main;
import std.stdio;
import a;
import b;
void main() {
with (a) {
// 11.19.1 Within the with body the referenced object is searched first
for identifier symbols
assert(f == "a");
// 4.3.2 When a symbol name is used unqualified, a two-phase lookup
will happen.
// First, the module scope will be searched, starting from the
innermost scope. ...
// Symbol lookup stops as soon as a symbol is found.
// If two symbols with the same name are found at the same lookup
phase,
// this ambiguity will result in a compilation error.
import b;
static if (__VERSION__ >= 2073) {
assert(f == "a");
} else {
assert(f == "b");
}
}
}
--
More information about the Digitalmars-d-bugs
mailing list