Issue 8922 - __traits(parent) should fail on top package import #1455

Merged
merged 1 commit into from Jan 19, 2013

Conversation

Projects
None yet
4 participants

ghost closed this Jan 10, 2013

ghost reopened this Jan 10, 2013

@9rnsr 9rnsr and 2 others commented on an outdated diff Jan 10, 2013

test/runnable/traits.d
@@ -967,6 +968,13 @@ void test5978() {
/*************************************************************/
+void test8922()
+{
+ static assert(!__traits(compiles, __traits(parent, imports)));
+ import imports.bug8922;
+ static assert(!__traits(compiles, __traits(parent, imports)));
+}
@9rnsr

9rnsr Jan 10, 2013

Member

I think we should consider more exhaustive cases.

  • Normal import import imports.bug8922; VS
    • __traits(parent, imports) : should be error, because imports has no parent. (== exactly the bug 8922)
    • __traits(parent, bug8922) : should return the package imports.
  • Static import static import imports.bug8922; VS
    • __traits(parent, imports) : should be error, because imports has no parent.
    • __traits(parent, bug8922) : should be error, because bug8922 is not found.
  • Selective import import renamed = imports.bug8922; VS
    • __traits(parent, renamed) : should return importing module (probably?)
    • __traits(parent, imports) : should be error, because imports is not found.
    • __traits(parent, bug8922) : should be error, because bug8922 is not found.

And for all cases, module level import VS function local import.

@ghost

ghost Jan 10, 2013

Will do, thanks.

@ghost

ghost Jan 10, 2013

@9rnsr: To try these various normal/static/selective imports I could use version blocks in a new test-file, e.g.:

version(Test1)
    import imports.bug8922;
else version(Test2)
    static import imports.bug8922;

The only problem is, how do I make the tester run the same test but with different arguments each time?

@yebblies

yebblies Jan 10, 2013

Member

Make several test cases, bug8922a, bug8922b, etc. You could probably do it with PERMUTE_ARGS but just duplicating the test cases will be clearer.

@ghost

ghost Jan 10, 2013

__traits(parent, bug8922) : should return the package imports.

That doesn't work in regular code, I get Error: undefined identifier bug8922 before it even reaches the trait.

@9rnsr

9rnsr Jan 10, 2013

Member

Oh, my bad. For all import kind, __traits(parent, bug8922) will be error. You are right.

Additionally, __traits(parent, imports.bug8922) :

  • returns the package imports with normal/static import.
  • makes an error with renamed import.
@ghost

ghost Jan 10, 2013

Thank you for your help! The test-cases are now updated.

ghost closed this Jan 10, 2013

ghost reopened this Jan 10, 2013

@WalterBright WalterBright added a commit that referenced this pull request Jan 19, 2013

@WalterBright WalterBright Merge pull request #1455 from AndrejMitrovic/Fix8922
Issue 8922 - __traits(parent) should fail on top package import
7d36ee4

@WalterBright WalterBright merged commit 7d36ee4 into dlang:master Jan 19, 2013

1 check passed

default Pass: 10
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment