Repository navigation
A map literal evaluates at compile time, empty or with pairs (part of #2220) - #3609
Merged
Merged
Conversation
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.
Part of #2220; the issue stays open.
let counts: HashMap[str, i32] = [:]inside acomptime fnwas "expression kind 128 is not comptime-evaluable yet", while the same function written withHashMap.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, asinsertdoes 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-testsgreen, and the ceremony census diff is clean; battery green. Evaluator only: no platform leg.