D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21353 - 'With()' statement ignores symbol visibility in some cases.
Summary: 'With()' statement ignores symbol visibility in some cases.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-11-01 06:08 UTC by Boris Carvajal
Modified: 2021-01-11 10:32 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Boris Carvajal 2020-11-01 06:08:55 UTC
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 Dlang Bot 2020-11-01 06:45:18 UTC
@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 Dlang Bot 2020-11-01 07:27:00 UTC
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 Dlang Bot 2020-11-16 00:10:12 UTC
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 Dlang Bot 2021-01-11 10:32:40 UTC
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