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

Implement hierarchical trait map and namespace lookups. #6516

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

tritao
Copy link
Contributor

@tritao tritao commented Sep 9, 2024

Description

This PR implements a hierarchical-based trait map and namespace lookup system while type checking.

Previously we added the concept of lexical concepts, which store all the names in a tree-based hierarchy.
But currently we still rely on a single "global" namespace, which is maintained by the type check context as we go down the tree. Thus, so far, all trait and namespace lookup have relied on looking up in that single namespace.

The main idea here is to be able to just rely on the names existing in the lexical scopes, and walk up those lexical scope chains as we need to lookup any name or trait.

The logic is split into these two commits:

Implement hierarchical trait map lookups.

Implement hierarchical namespace lookups.

This PR still does not remove that cloning, which will be done in a separate future PR.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@tritao tritao self-assigned this Sep 23, 2024
@tritao tritao force-pushed the hierarchical-lookups-typechecker branch 2 times, most recently from 60db3a9 to 486df45 Compare November 18, 2024 01:28
@tritao tritao changed the title Implement hierarchical namespace lookups. Implement hierarchical trait map and namespace lookups. Nov 18, 2024
@tritao tritao added the compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen label Nov 18, 2024
Copy link

codspeed-hq bot commented Nov 18, 2024

CodSpeed Performance Report

Merging #6516 will not alter performance

Comparing tritao:hierarchical-lookups-typechecker (e18803c) with master (07dfa55)

Summary

✅ 22 untouched benchmarks

@tritao tritao marked this pull request as ready for review November 18, 2024 01:44
@tritao tritao requested review from a team as code owners November 18, 2024 01:44
esdrubal
esdrubal previously approved these changes Nov 26, 2024
Copy link
Contributor

@jjcnn jjcnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good, but I think there's a common pattern that can be abstracted out, and there's a nagging feeling at the back of my mind that you've introduced a shadowing issue. Let me know what you think - I might just be overthinking things.

@tritao tritao force-pushed the hierarchical-lookups-typechecker branch 2 times, most recently from c8f6cb0 to 4003178 Compare December 2, 2024 03:27
@tritao
Copy link
Contributor Author

tritao commented Dec 2, 2024

Addressed all the review feedback, now walking of scope chains is abstracted into an helper.

@tritao tritao requested a review from a team December 2, 2024 03:42
jjcnn
jjcnn previously approved these changes Dec 2, 2024
esdrubal
esdrubal previously approved these changes Dec 2, 2024
@tritao tritao dismissed stale reviews from esdrubal and jjcnn via e7476b6 December 2, 2024 12:46
@tritao tritao force-pushed the hierarchical-lookups-typechecker branch from 4003178 to e7476b6 Compare December 2, 2024 12:46
@tritao tritao force-pushed the hierarchical-lookups-typechecker branch from e7476b6 to e18803c Compare December 2, 2024 13:02
@tritao tritao requested review from esdrubal and jjcnn December 2, 2024 13:19
@tritao tritao requested review from sdankel and a team December 2, 2024 13:25
@tritao tritao merged commit 5423c56 into FuelLabs:master Dec 2, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants