[Issue 21353] New: 'With()' statement ignores symbol visibility in some cases.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 1 06:08:55 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21353
Issue ID: 21353
Summary: 'With()' statement ignores symbol visibility in some
cases.
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: boris2.9 at gmail.com
Bug exposed while looking at issue 21351
imp.d
------------------
struct A { int x; }
struct B { import imp : A; } // imports are private by default
private struct P { }
test.d
------------------
import imp;
void main()
{
B.A;
with (B) { A(0); }
with (B()) { A(0); }
imp.P();
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
int
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.
--
More information about the Digitalmars-d-bugs
mailing list