Bug 21353 – 'With()' statement ignores symbol visibility in some cases.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-11-01T06:08:55Z
Last change time
2021-01-11T10:32:40Z
Keywords
pull
Assigned to
No Owner
Creator
Boris Carvajal
Comments
Comment #0 by boris2.9 — 2020-11-01T06:08:55Z
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.
Comment #1 by dlang-bot — 2020-11-01T06:45:18Z
@BorisCarvajal created dlang/dmd pull request #11918 "Fix Issue 21353 - 'With()' statement ignores symbol visibility in som…" fixing this issue:
- Fix Issue 21353 - 'With()' statement ignores symbol visibility in some cases
https://github.com/dlang/dmd/pull/11918
Comment #2 by dlang-bot — 2020-11-01T07:27:00Z
dlang/dmd pull request #11918 "Fix Issue 21353 - 'With()' statement ignores symbol visibility in som…" was merged into stable:
- 49b60b00c55766514f834d3defc54ce45c0d4ede by Boris Carvajal:
Fix Issue 21353 - 'With()' statement ignores symbol visibility in some cases
https://github.com/dlang/dmd/pull/11918
Comment #3 by dlang-bot — 2020-11-16T00:10:12Z
dlang/dmd pull request #11961 "merge stable" was merged into master:
- 71d49af154297b4c4cab2e2b61b2bcd1c29bdf81 by Boris Carvajal:
Fix Issue 21353 - 'With()' statement ignores symbol visibility in some cases
https://github.com/dlang/dmd/pull/11961
Comment #4 by dlang-bot — 2021-01-11T10:32:40Z
dlang/dmd pull request #12125 "[dmd-cxx] Fix Issue 21353 - 'with()' statement ignores symbol visibility in some cases" was merged into dmd-cxx:
- 64a7adac3ba982a5bee7f3902b7aa27a737d697f by Boris Carvajal:
[dmd-cxx] Fix Issue 21353 - 'with()' statement ignores symbol visibility in some cases
https://github.com/dlang/dmd/pull/12125