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

DDC is incorrectly hoisting types #30912

Closed
vsmenon opened this issue Sep 27, 2017 · 4 comments
Closed

DDC is incorrectly hoisting types #30912

vsmenon opened this issue Sep 27, 2017 · 4 comments
Assignees
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler

Comments

@vsmenon
Copy link
Member

vsmenon commented Sep 27, 2017

The following:

class Foo {
}

class Bar {
}

typedef Type Func<S extends Foo, T>(T s);

class Baz<S extends Foo, T extends Bar> {
  Func<S, Bar> func;
}

void main() {
  dynamic baz = new Baz();
  print(baz.func);
}

fails with:

ReferenceError: S is not defined ReferenceError: S is not defined
@vsmenon vsmenon added web-dev-compiler P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Sep 27, 2017
@vsmenon
Copy link
Member Author

vsmenon commented Sep 27, 2017

@jmesserly @leafpetersen - can one of you take a look? If I can Func<S, Bar> to Func<S, T>, no error - looks like a bug in the hoist logic.

@jmesserly jmesserly self-assigned this Sep 27, 2017
@jmesserly
Copy link

I can take a look. I hope it's not an instance of #30379 (because that one is showing up everywhere lately).

@jmesserly
Copy link

The reason this is broken is that S is not used in the function type, so it doesn't appear at all after the typedef has been instantiated. The function type is just (Bar) -> Type, so no free variables, and hoisting is legal. The problem is we emit it using the typedef (to preserve the name perhaps).

I'm guessing no one has hit this combo before, as unused type parameters aren't super common.

Shouldn't be too hard to fix.

@jmesserly
Copy link

@whesse whesse closed this as completed in 13b57ce Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler
Projects
None yet
Development

No branches or pull requests

2 participants