feat: support generic struct literals (coverage C2b) - #21
Open
EpsilonPrime wants to merge 1 commit into
Open
Conversation
Generic struct literals were parsed to i64(0) (only interval-typed `{}`
literals were handled) and printed as STRUCT_LITERAL_NOT_YET_IMPLEMENTED.
- Parser: add build_struct_literal, routing both the non-interval type-suffix
case and the suffix-less case to a real LiteralType::Struct (fields built
recursively via build_constant). Interval `{}` literals are unchanged.
- Printer: emit `{field, field, ...}` recursively.
Adds a text -> binary -> text round-trip test with a heterogeneous struct
`{1_i32, "hello"}`; updates COVERAGE.md.
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.
Coverage PR C2b (stacked on C2 #20). Implements generic struct literals.
What
Only interval-typed
{}literals were handled; a generic struct fell through toi64(0), and the printer stubbedStruct.build_struct_literalbuildsLiteralType::Struct(fields recursively viabuild_constant). Both the non-interval type-suffix case and the suffix-less case route to it. Interval{}literals ({y,m}_interval_year_month,{d,s,us}_interval_day_second) are untouched — the type suffix still routes them.{field, field, ...}recursively.The
{}overloading is resolved by dispatch::→ map, interval suffix → interval, otherwise → struct.Tests
test_roundtrip_struct_literal: heterogeneous{1_i32, "hello"}round-trips text→binary→text.Remaining in the
{}family: C2c — list + empty-list/empty-map literals (need new grammar).