parser: allow Map (and comma-bearing generics) as class state fields - #14
Merged
Conversation
The state-block init-token collector tracked (), [], and {} depth but not <>, so
the comma inside a generic default such as `= empty Map<String, Integer>` read
as depth-zero and ended the field early. That left a garbled state block, and
the alias workaround (`type IntMap = Map<...>`) hit a second issue where
`empty <alias>` emits a null {0} struct, crashing at first use. Track <> in the
collector so a Map (or any comma-bearing generic) can be a class state field
directly, constructed properly by the existing empty Map<...> codegen.
The metrics Meter (std/monitoring/instruments.xi) now uses Maps directly with
O(1) lookups instead of a scanned list. Regression test in
examples/language/map_state_test.xi; the self-host fixpoint holds and all
existing tests pass.
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.
The
state { }init-token collector tracked(),[], and{}depth but not<>, so the comma inside a generic default such as= empty Map<String, Integer>read as depth-zero and ended the field early. The result was a garbled state block; the alias workaround (type IntMap = Map<...>) then hit a second issue whereempty <alias>emits a null{0}struct that crashes at first use.Fix
Track
</>(token kinds 114/115) in the collector, so aMap(or any comma-bearing generic) can be a classstatefield directly. Construction goes through the existing, correctempty Map<...>codegen path, so no{0}and no alias needed:Follow-through
The metrics
Meter(std/monitoring/instruments.xi, added with the tracing suite) used a scannedList<compound>to work around this. It now usesMaps directly with O(1) lookups, dropping ~40 lines.Verification
examples/language/map_state_test.xi.Map<String, SomeCompound>(compound values) is not monomorphized; useList<compound>there.