-
Notifications
You must be signed in to change notification settings - Fork 108
Eliminate generated ident collisions #2355
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
base: master
Are you sure you want to change the base?
Conversation
|
As discussed in the weekly, maybe instead of having a special path for pattern compilation/idents, pattern compilation should use arrays instead of records. There's a more general design decision about whether we should be interning as much as we do right now. Maybe not everything that's currently Ident should be interned? (Like, maybe only intern at parsing time?) |
8a03c2e to
9add184
Compare
|
With the latest pattern compilation changes, this still runs into issues with the fresh identifiers coming from generated contracts. I think the more thorough pattern compilation re-work is still a prerequisite for this. |
9add184 to
7543613
Compare
|
With the new pattern compilation, I think this is finally ok. I tested it by adding a panic whenever |
This changes ident generation so that idents generated with
Ident::freshwill never clash with idents generated withIdent::new. I think this was the originally intended behavior, but as discussed in the now-deleted docs forIdent::fresh, it didn't work.There was a problem with pattern compilation, though, which used to generate idents with
Ident::fresh, then turn those idents into strings to pass to%record/insert%. These strings would get turned back into idents viaIdent::newand then they'd no longer match the original fresh idents.I originally tried to solve this by having a special-case
Ident::fake_freshthat was only used in pattern compilation to revert to the old behavior. It didn't work, because pattern compilation sometimes consumes fresh identifiers coming from other places.So this PR takes another approach, by allowing record primops to take either an ident (represented as an enum tag) or a string. I'm not sure this is the right approach, and it probably has conflicts with #2302... As discussed somewhere (I can't find it ATM) the better approach might be to revisit how pattern compilation collects its bindings.