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

Improve name resolution for top-level scope, structs and enums #47

Closed
denismerigoux opened this issue Jan 3, 2021 · 0 comments
Closed
Labels
🔧 compiler Issue concerns the compiler ✨ enhancement New feature or request 👌 good first issue Good for newcomers 👪 help wanted Extra attention is needed

Comments

@denismerigoux
Copy link
Contributor

Right now, name resolution is done in two passes (in file src/catala/catala_surface/name_resolution.ml):

  1. Look at scope, struct and enum declarations in order and create identifiers for them and their fields/cases/context
  2. Look at scope uses and link the identifiers to the ones created in 1.

This is nice but lacks flexibility for scope, structs and enums. Especially, we want users to be able to declare their scope anywhere in the code, and not following a dependency order. For instance, if scope A has a subscope of type B, we don't want to force the user to declare B before A.

This problem can be solved by doing a three-pass name resolution with the following passes:

  1. Look at scope, struct and enum declarations and create identifiers for them
  2. Look at fields/cases/context are create identifiers for them, also possibly linking to the scope/struct/enum identifiers of 1.
  3. Look at scope uses and link the identifiers to the ones created in 1. and 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 compiler Issue concerns the compiler ✨ enhancement New feature or request 👌 good first issue Good for newcomers 👪 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant