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

[DSLX] Add support for use statement in TI/interp. #1842

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cdleary
Copy link
Collaborator

@cdleary cdleary commented Jan 10, 2025

(Note that support for use is still gated behind a feature flag.)

Use statements introduce the notion of "extern refs" -- i.e. NameRefs that actually indicate things whose definitions live in other modules. Previously we knew more directly when we were referring to an extern definition because it would go through a ColonRef.

This introduces first handling of extern refs and support for imports via the use construct. You still cannot use a module directly, just entities defined inside of it -- we'll maybe want something like a "Module" type to keep in the TypeInfo when we introduce the ability to use a module directly, but I also didn't want to mess with anything that could affect type inference v2 work, so this focuses on direct use of definitions into the module scope.

Still also no support for "use *", I don't feel compelled to add support for that in any short order since it's also not usually a good practice and the mitigation of "type more" is not bad.

Summary of changes:

  • Handle extern refs in the bytecode interpreter and constexpr evaluator
  • Ability to linearize a use tree to definitions inside the module that should be imported
  • Refactoring of routines for handling import statements to similarly handle use statements
  • IR conversion FunctionConverter support for handling extern refs
  • Some better invariants for ScopedTypeInfoSwap guard in the IR converter
  • Typecheck support for traversing use statements at module scope
  • FakeFilesystem that just takes a map for multi-module scenarios (vs UniformContentFilesystem which only supported one file)
  • LSP test that the use-bound symbols are shown in the results

Towards #352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant