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

Create an Elaborator #5146

Closed
Tracked by #4594
jfecher opened this issue May 30, 2024 · 0 comments · Fixed by #5145
Closed
Tracked by #4594

Create an Elaborator #5146

jfecher opened this issue May 30, 2024 · 0 comments · Fixed by #5145
Assignees
Labels
enhancement New feature or request

Comments

@jfecher
Copy link
Contributor

jfecher commented May 30, 2024

Problem

The original metaprogramming paper: https://hackmd.io/Tkzo_ryvTsWMPESmWHPiZw?view detailed a meta-circular evaluator architecture to expand macros, however after much experimentation this was more difficult than it seemed.

Happy Case

As an alternative to the meta-circular evaluator, we can implement an elaborator which combines name resolution, type checking, and comptime interpretation into one pass. Since each expression will be name resolved, type checked, and evaluated simultaneously, code that is expanded from a macro can be treated as normal code to be elaborated next.

This would replace our type checking, name resolution, and comptime scanning passes.

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@jfecher jfecher added the enhancement New feature or request label May 30, 2024
@jfecher jfecher self-assigned this May 30, 2024
github-merge-queue bot pushed a commit that referenced this issue May 30, 2024
…or` flag is specified (#5145)

# Description

## Problem\*

Resolves #5146

Fixes all failing frontend tests with the elaborator

## Summary\*

This PR includes a few fixes:
- Use `check_trait_impl_method_matches_declaration` to issue errors when
a trait impl method is declared with an incorrect signature.
- `define_function_meta` for default trait functions on impls when
they're copied over. Also make sure to set `self.current_trait_impl` and
`self.self_type` for them as well.
- Use `try_get_trait_implementation` when getting a trait impl may fail
(which may happen if there was a previous error resolving the trait for
that impl). This was triggering on the test where we tried to declare a
trait impl implementing a struct rather than a trait.
- `check_trait_wrong_parameter_type` has a duplicate error on master but
not in the elaborator so I changed the expected error count there.

## Additional Context

After this PR all existing code _should_ work with the elaborator and we
can get the word out to get others testing the `--use-elaborator` flag
for any errors/panics.

## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
1 participant