Skip to content

A map literal evaluates at compile time, empty or with pairs (part of #2220) - #3609

Merged
ehartford merged 2 commits into
mainfrom
comptime-map-literal
Nov 25, 2026
Merged

ehartford merged 2 commits into
mainfrom
comptime-map-literal

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Part of #2220; the issue stays open.

let counts: HashMap[str, i32] = [:] inside a comptime fn was "expression kind 128 is not comptime-evaluable yet", while the same function written with HashMap.new() evaluated. The evaluator had no case for the map literal node. It has one now: the pairs in order, a later pair replacing an earlier one with an equal key, as insert does and as the literal behaves at run time.

Test: behav_2220_comptime_map_literal (the empty literal filled in a loop, a literal with pairs and a repeated key, and the run-time literal agreeing with the compile-time one). It fails on main.

Evidence at 1ed6c9c: both compilers check the source; release build; :unit-return-review, :self-audit, :behavior-tests green, and the ceremony census diff is clean; battery green. Evaluator only: no platform leg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant