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: detect error when trying to use unbound generic type in instance var #6128

Merged
merged 1 commit into from Jun 12, 2018

Conversation

asterite
Copy link
Member

Fixes #5383

Sorry, this one is a bit hard to explain, why the fix works. But basically, an uninstantiated generic type should only be instantiated with available free vars, not all the time (in the new test case, T shouldn't be found because we are trying to find instance vars of Foo, and so Gen(T) shouldn't be a valid type for an instance var of Foo (it could be valid for an instance var of Gen(T), but that's not the case).

@RX14
Copy link
Contributor

RX14 commented May 24, 2018

I think this fix is fine, but I think the error message is weird to me. Shouldn't we print the long Can't infer the type of instance variable '@x' of Foo? We can't infer the type of Gen(T).new in the ivars pass because it's a class method without an explicit (enough) return type annotation.

@asterite
Copy link
Member Author

I won't be coding anymore for a while, so if somebody wants to improve this, either modify it after this PR, in this PR or send a separate PR.

@asterite asterite closed this May 28, 2018
@asterite asterite reopened this Jun 11, 2018
@asterite
Copy link
Member Author

asterite commented Jun 11, 2018

Come on, just please merge this for 0.25.0. A guy just stumbled upon this error and nobody seems to notice it's a duplicate (for like a thousand times). A wise guy once said to me that it's better to make small progress instead of wanting to attain perfection. I believe this error message is better than an internal compiler error.

Take it or leave it.

@RX14
Copy link
Contributor

RX14 commented Jun 11, 2018

It's too late for 0.25.0, it's already been tagged and built, just waiting to be signed and released.

I'm sure we can get this in for 0.25.1.

@RX14 RX14 added this to the 0.25.1 milestone Jun 11, 2018
@ysbaddaden ysbaddaden merged commit d9b024e into master Jun 12, 2018
@ysbaddaden ysbaddaden deleted the bug/5383-unbound-generic-type branch June 12, 2018 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE with untyped Array as instance var initializer
3 participants