www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19305] New: In symbol lookup, with statement becomes stronger


          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 puremagic.com
          Reporter: shigekikarita 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

running example 

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
        //  this ambiguity will result in a compilation error.
        import b;
        static if (__VERSION__ >= 2073) {
            assert(f == "a");
        } else {
            assert(f == "b");                    

Oct 12 2018