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 compiler crash related to type parameter references #3725

Merged
merged 1 commit into from
Feb 28, 2021

Conversation

Trundle
Copy link
Contributor

@Trundle Trundle commented Feb 28, 2021

This fixes a bug in rescoping. Rescoping happens after a method was
copied from a trait/interface to another type. It starts with a fresh
scope, visits all of the method's AST nodes and adds the visited symbols
to the method's symbol table. This includes type parameters. If a type
parameter reference is visited, the referenced type parameter is looked
up and added as data to the node.

As rescoping starts with a fresh scope, adding the type parameter to the
reference fails if the type parameter itself is not defined yet. This is
fixed by eagerly adding type parameters to the scope before visiting
type parameter references.

Fixes #3285

This fixes a bug in rescoping. Rescoping happens after a method was
copied from a trait/interface to another type. It starts with a fresh
scope, visits all of the method's AST nodes and adds the visited symbols
to the method's symbol table. This includes type parameters. If a type
parameter reference is visited, the referenced type parameter is looked
up and added as data to the node.

As rescoping starts with a fresh scope, adding the type parameter to the
reference fails if the type parameter itself is not defined yet. This is
fixed by eagerly adding type parameters to the scope before visiting
type parameter references.

Fixes ponylang#3285
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Feb 28, 2021
@SeanTAllen
Copy link
Member

@Trundle you are making me smile so much lately. thank you.

@SeanTAllen SeanTAllen merged commit 57cc552 into ponylang:main Feb 28, 2021
github-actions bot pushed a commit that referenced this pull request Feb 28, 2021
github-actions bot pushed a commit that referenced this pull request Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler assert failure crash with interface default implementations
2 participants