Built-in Map and Set collections (pipe-fence [|K => V|] / [|T|]) - #160
Open
assapir wants to merge 8 commits into
Open
Built-in Map and Set collections (pipe-fence [|K => V|] / [|T|])#160assapir wants to merge 8 commits into
assapir wants to merge 8 commits into
Conversation
Lexer, parser, AST, checker, codegen, and runtime for built-in Map/Set (pipe-fence [|K => V|] / [|T|]) all build warning-clean and pass smoke tests via JIT and AOT. Intrinsic link gate extended. Dedicated test file, example, and LANGUAGE.md still to come. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Also apply rustfmt to the collections codegen/runtime modules. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Correctness (from review): - Canonicalize Num keys: -0.0 unifies with +0.0 (matches float ==), and NaN collapses to one self-equal key. Adds two run tests. - Fix: an identifier map key (`[|k => v|]`) was mis-parsed as a lambda; keys now parse with lambda detection suppressed. - Document the persistent-collection native-heap leak trade-off. Simplification (from review): - Extract build_conditional_result helper shared by array .at and map .get. - Move Map/Set .size codegen into collections.rs reusing call_rt_int. - Factor __set_diff/__set_intersect into set_filter; minor consistency nits. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adapt the Map/Set pipeline to code that landed on main while this branch was parked: - Add MapLit/SetLit arms to the deferred-value analysis (deferral.rs) and the reachability walk (reachability.rs), both introduced after this branch forked. Literal keys/values/elements are strict slots that deliver a ready value. - Drop collections.rs's local int_to_bool in favour of the shared helper main added to text.rs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Apply the read-only review passes: - Remove the decorative section-divider banners in the collections codegen, runtime, and test files, and the per-intrinsic C-prototype comments that restated the LLVM signature on the next line; keep the load-bearing ABI/GC notes and short semantic annotations. - Spell out runtime identifiers: snap_a/snap_b/snap_v become snapshot_a/snapshot_b/snapshot_values, key_desc becomes key_description; the map-literal parser's value binding is `value`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Built-in
MapandSetcollection types — the first slice of #72. These are built-in parametric collection primitives (like[]T), not user-defined generics.What's implemented (built-in keys only)
[|K => V|], literal[|"a" => 1|], empty[|=>|]; Set type[|T|], literal[|"a", "b"|], empty[||]. The fence keeps a set literal distinct from an array literal.m[k]returns the value and crashes on a missing key;m.get(k)is the safeOk(v)/NotOkform.get/has/set/keys/values/each+ the.sizefield. Set:has/add/items/each+.size.+union,-difference,+-(=-+) intersection (single-token symmetric operators; whitespace disambiguates from+ -, per the locked design).std::collections::HashMap/HashSetinquilon-rtover GC memory. Keys are the built-in hashable types (Num / Text / Bool; Text hashes by content, consistent with value==).BuildHasherkeeps programs reproducible run-to-run (order is unspecified by contract, not insertion order).intrinsic_registry!macro; theintrinsic_link_testreaches every one under both linkers.Deferred to a later slice (per #72)
%/==hooks and their compile-time pairing + debug-build consistency check.remove.^'s env over as a[|Text => Text|]map (andcore.cli'sgetEnvadaptation).Ships with
docs/LANGUAGE.md: Maps and Sets section, symbol-table entries, and feature-matrix rows.tests/collections_test.rs: run + type-error suite; a subprocess test for the fail-loudm[k]miss.examples/maps_and_sets.ql: a self-asserting demo (order-independent asserts only).Notes for review
main(concurrency runtime, deferred values,docs/corelibsplit). Conflicts were clean unions in the intrinsic registry and codegen; newMapLit/SetLitarms were added tomain's post-forkdeferral.rs/reachability.rs.🤖 Generated with Claude Code