www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21353] New: 'With()' statement ignores symbol visibility in


          Issue ID: 21353
           Summary: 'With()' statement ignores symbol visibility in some
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: boris2.9 gmail.com

Bug exposed while looking at issue 21351

struct A { int x; }
struct B { import imp : A; }  // imports are private by default
private struct P { }

import imp;

void main()
    with (B) { A(0); }
    with (B()) { A(0); }

    with (imp) { P(); }

The above code fails with the following output:

test.d(5): Error: no property A for type imp.B
test.d(6): Error: no property A for type imp.B
test.d(7): Error: cannot implicitly convert expression __withSym of type B* to
test.d(9): Error: undefined identifier P in module imp
test.d(10): Error: P() has no effect

Note that lines 7 and 10 should fail with same error as theirs respective forms
without 'with' statement because the symbols A and P are private.

Oct 31 2020