You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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");
}
}
}
The text was updated successfully, but these errors were encountered:
I don't see what the problem is. master git HEAD compiles this successfully as it should. The with scope takes precedence over imports. The rules are clear. Maybe older versions had a bug in it which was solved.
Closing as invalid. Please reopen if I am missing something.
karita (@ShigekiKarita) reported this on 2018-10-13T04:48:24Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=19305
CC List
Description
The text was updated successfully, but these errors were encountered: