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

Use symbol table from definition scope when looking up references from default method bodies #4027

Merged
merged 14 commits into from
Feb 22, 2022

Conversation

SeanTAllen
Copy link
Member

@SeanTAllen SeanTAllen commented Feb 21, 2022

We've had issues with symbols within trait and interface default method bodies. If symbols used within those bodies were not available in the local scope that the method bodies were added to, the symbols couldn't be found.

The issue was that we were only searching the local scope.

This change adds an additional AST symbol lookup strategy where we look for a function or behavior as our parent. If one exists, we check to see if it was provided by a trait. This is done by looking to see if the AST data is present. If it is, then that is the AST for original trait implementation of the method. We can then use that AST node to find symbols that were present at the original declaration site of the trait.

Fixes #3737
Fixes #2150

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 21, 2022
@SeanTAllen
Copy link
Member Author

The actual implementation code needs to get cleaned up. It's a copy n paste to make sure all tests are passing in CI situation at the moment.

@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Feb 21, 2022
@ponylang-main
Copy link
Contributor

Hi @SeanTAllen,

The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 4027.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

@SeanTAllen SeanTAllen changed the title Use symbol table from definition scope when looking up references for default method bodies Use symbol table from definition scope when looking up references from default method bodies Feb 22, 2022
@SeanTAllen
Copy link
Member Author

When this is squashed and merged, the top comment should be used as the commit comment.

@SeanTAllen SeanTAllen marked this pull request as ready for review February 22, 2022 01:22
@SeanTAllen SeanTAllen merged commit 7766335 into main Feb 22, 2022
@SeanTAllen SeanTAllen deleted the sean-plays-with-traits branch February 22, 2022 19:42
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 22, 2022
github-actions bot pushed a commit that referenced this pull request Feb 22, 2022
github-actions bot pushed a commit that referenced this pull request Feb 22, 2022
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
3 participants