Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 13096 - Imported private identifiers conflict with public ones #3743

Closed
wants to merge 1 commit into from
Closed

Fix 13096 - Imported private identifiers conflict with public ones #3743

wants to merge 1 commit into from

Conversation

yglukhov
Copy link
Contributor

Fix 13096

@@ -913,6 +913,9 @@ Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags)
/* Don't find private members if ss is a module
*/
Dsymbol *s2 = ss->search(loc, ident, ss->isModule() ? IgnorePrivateMembers : IgnoreNone);
if (s && s2 && ss->isModule() && s2->prot() == PROTprivate)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not sufficient whtn s2 is function, template, or overloaded alias.

@yglukhov
Copy link
Contributor Author

@9rnsr, added your use-cases to tests. Except for overloaded alias, which I can't quite understand what you mean by. The tests seem to pass. Did I miss anything?

@9rnsr
Copy link
Contributor

9rnsr commented Jul 11, 2014

I meant that

void foo1() {}
void foo2(int) {}

private alias foo = foo1;
public alias foo = foo2;
// in here, foo is an overloaded alias

And this fix would break following case:

// test13096_private.d
private void foo() {}
public  void foo(int) {}
// test13096_public.d
void foo(string) {}
// test13096.d
import imports.test13096_public;
import imports.test13096_private;
void main()
{
    static assert(!__traits(compiles, foo()));
    foo(1);
    foo("str");
}

@yglukhov
Copy link
Contributor Author

@9rnsr, you're totally right. I've updated the code to not mess with overloadable symbols. Overloadables are still to be fixed, but it seems like it should be done elsewhere (e.g. resolveFuncCall(), etc).

@quickfur
Copy link
Member

Issue 13096 seems to be a duplicate of issue 1238.

@ghost ghost changed the title Fix 13096. Fix 13096 - Imported private identifiers conflict with public ones Aug 4, 2014
@DmitryOlshansky
Copy link
Member

The single most annoying bug. I'm really impressed we have gone this far without fixing it.

@quickfur
Copy link
Member

Yeah, when is this PR gonna get merged? It's just asking for an embarrassing failure in enterprise code when somebody accidentally adds private symbols to one module and causes breakage in other, unrelated modules.

@vl-01
Copy link

vl-01 commented Nov 1, 2014

Seconding this, I've got a somewhat complicated module hierarchy and this
bug gets in my way on a regular basis. It screws up UFCS and declaring
"alias conflicted_symbol = some_module.conflicted_symbol" doesn't actually
do anything.

On Oct 31, 2014 5:09 PM, "H. S. Teoh" notifications@github.com wrote:

Yeah, when is this PR gonna get merged? It's just asking for an
embarrassing failure in enterprise code when somebody accidentally adds
private symbols to one module and causes breakage in other, unrelated
modules.


Reply to this email directly or view it on GitHub
#3743 (comment)
.

@ghost
Copy link

ghost commented Dec 6, 2014

The fix looks simple enough that it's worth merging. The commits will have to be squashed to one commit though.

@9rnsr any objections for this pull?

@quickfur
Copy link
Member

quickfur commented Dec 6, 2014

It's just two commits, is a squash really necessary?

In any case, it's high time we merged this (barring objection by Walter & co), this is one of the embarrassing gaps in D's module system that greatly detracts from it.

@ghost
Copy link

ghost commented Dec 6, 2014

It's just two commits, is a squash really necessary?

Well it's 3 commits, and AFAICT one commit adds code which the next commit removes (so they cancel each other out, and they're just noise at that point).

@quickfur
Copy link
Member

quickfur commented Dec 6, 2014

Right, I missed the third one. Ignore what I just said. :-P

@yglukhov
Copy link
Contributor Author

Rebased and squashed.

@quickfur
Copy link
Member

quickfur commented Jan 1, 2015

LGTM

@ghost
Copy link

ghost commented Jan 1, 2015

Pinging @9rnsr again since he knows more about this.

@MetaLang
Copy link
Member

MetaLang commented Feb 1, 2015

The fact that this bug has been around since 2007 is crazy. This needs merging post-haste.

@9rnsr
Copy link
Contributor

9rnsr commented Mar 22, 2015

Please add the test case that I've shown.

else if (ss->isModule() && s2->prot() == PROTprivate)
{
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not bad, but does cover all cases?

  1. ss is an overloadable public symbol, and
    a. s2 is an overloadable public symbol.
    b. s2 is an overloadable private symbol.
    c. s2 is an non-overloadable public symbol.
    d. s2 is an non-overloadable private symbol.
  2. ss is an overloadable private symbol, and
    a. s2 is an overloadable public symbol.
    b. s2 is an overloadable private symbol.
    c. s2 is an non-overloadable public symbol.
    d. s2 is an non-overloadable private symbol.
  3. ss is an non-overloadable public symbol, and
    a. s2 is an overloadable public symbol.
    b. s2 is an overloadable private symbol.
    c. s2 is an non-overloadable public symbol.
    d. s2 is an non-overloadable private symbol.
  4. ss is an non-overloadable priate symbol, and
    a. s2 is an overloadable public symbol.
    b. s2 is an overloadable private symbol.
    c. s2 is an non-overloadable public symbol.
    d. s2 is an non-overloadable private symbol.

@mathias-lang-sociomantic
Copy link
Contributor

This issue have been fixed. I think we can safely close this.

@yglukhov yglukhov closed this Sep 27, 2016
@yglukhov yglukhov deleted the fix13096 branch September 27, 2016 18:59
ibuclaw pushed a commit to ibuclaw/dmd that referenced this pull request Jul 10, 2022
core: Remove declarations with expired deprecations

Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants