feat: add names arena and thread 'names lifetime through IR#42
Merged
iljakuklic merged 6 commits intodevelfrom Apr 6, 2026
Merged
feat: add names arena and thread 'names lifetime through IR#42iljakuklic merged 6 commits intodevelfrom
iljakuklic merged 6 commits intodevelfrom
Conversation
Introduces a dedicated `names_arena: Bump` that owns all identifier strings for the lifetime of the pipeline. Only `lexer::Lexer` calls `alloc_str`; every downstream layer (parser, checker, staging) reuses the existing `&Name` references without re-allocating. To express this, AST and core IR types gain a separate `'n` lifetime parameter for name references, distinct from the structural allocation lifetime `'a`. The elaboration bound changes from `'src: 'core` to `'n: 'core`, which lets `ast_arena` be dropped before `core_arena` in the pipeline, as intended. Closes #28 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- `'n` → `'names` everywhere (names arena) - `'a` → `'ast` in parser and checker function signatures (AST arena) - `'a` → `'eval` for ObjVal/ObjArm in staging (eval arena) - `'a` → `'names` for Token and Lexer (names arena) - `'c` → `'core` in elaborate_sig (core arena) - `'t` → `'a` in core::Arm and core::Function (normalise with other structs) The `'a` parameter in core IR type definitions (Term, Pi, Lam, etc.) remains `'a` as it is polymorphic over 'core/'eval/'out. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…arsing Lexer<'src, 'names> separates the source text lifetime from the names arena lifetime. The iterator now yields Token<'names>, making it clear that produced tokens outlive the source string. In the CLI pipeline, source is dropped immediately after parse_program returns, since all identifier strings are interned in names_arena. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
iljakuklic
commented
Apr 6, 2026
Owner
Author
iljakuklic
left a comment
There was a problem hiding this comment.
Just two minor comments:
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
iljakuklic
commented
Apr 6, 2026
Owner
Author
iljakuklic
left a comment
There was a problem hiding this comment.
Addressed in aff27f7: inlined param_name in both the Pi and Lam elaboration loops.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces a dedicated
names_arena: Bumpthat owns all identifier strings for the lifetime of the pipeline. Onlylexer::Lexercallsalloc_str; every downstream layer (parser, checker, staging) reuses the existing&Namereferences without re-allocating.To express this, AST and core IR types gain a separate
'nlifetime parameter for name references, distinct from the structural allocation lifetime'a. The elaboration bound changes from'src: 'coreto'n: 'core, which letsast_arenabe dropped beforecore_arenain the pipeline, as intended.