Fix eager typecheck of Map (#1654)

Closes #1653
This commit is contained in:
Daniel Chao
2026-06-05 11:24:00 -07:00
committed by GitHub
parent 87ec8ee730
commit aa01241068
3 changed files with 7 additions and 1 deletions
@@ -1543,7 +1543,7 @@ public abstract class TypeNode extends PklNode {
if (skipEntryTypeChecks) return value; if (skipEntryTypeChecks) return value;
for (var entry : value) { for (var entry : value) {
keyTypeNode.executeEagerly(frame, VmUtils.getKey(entry)); keyTypeNode.executeEagerly(frame, VmUtils.getKey(entry));
valueTypeNode.executeLazily(frame, VmUtils.getValue(entry)); valueTypeNode.executeEagerly(frame, VmUtils.getValue(entry));
} }
LoopNode.reportLoopCount(this, value.getLength()); LoopNode.reportLoopCount(this, value.getLength());
@@ -1,5 +1,9 @@
amends "../snippetTest.pkl" amends "../snippetTest.pkl"
local class Animal
local class Person
facts { facts {
["List"] { ["List"] {
List(1, 2, 3) is List<Int> List(1, 2, 3) is List<Int>
@@ -16,6 +20,7 @@ facts {
["Map"] { ["Map"] {
Map("Pigeon", 42, "Barn Owl", 21) is Map<String, Int> Map("Pigeon", 42, "Barn Owl", 21) is Map<String, Int>
!(Map("Pigeon", 42, "Barn Owl", 21) is Map<Int, String>) !(Map("Pigeon", 42, "Barn Owl", 21) is Map<Int, String>)
!(Map("bob", new Listing { new Animal {} }) is Map<String, Listing<Person>>)
} }
["Listing"] { ["Listing"] {
@@ -12,6 +12,7 @@ facts {
["Map"] { ["Map"] {
true true
true true
true
} }
["Listing"] { ["Listing"] {
true true