Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion conformance/src/test/java/dev/cel/conformance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ _TESTS_TO_SKIP_PLANNER = [
"timestamps/timestamp_range/sub_time_duration_under",

# Skip until fixed.
"fields/qualified_identifier_resolution/map_value_repeat_key_heterogeneous",
"optionals/optionals/map_null_entry_no_such_key",
"optionals/optionals/map_present_key_invalid_field",
"parse/receiver_function_names",
Expand Down
17 changes: 15 additions & 2 deletions runtime/src/main/java/dev/cel/runtime/planner/EvalCreateMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,26 @@ public Object eval(GlobalResolver resolver, ExecutionFrame frame) throws CelEval
keyInterpretable.exprId());
}

Object val = values[i].eval(resolver, frame);
boolean isDuplicate = !keysSeen.add(key);
if (!isDuplicate) {
if (key instanceof Long) {
long longVal = (Long) key;
if (longVal >= 0) {
isDuplicate = keysSeen.contains(UnsignedLong.valueOf(longVal));
}
} else if (key instanceof UnsignedLong) {
UnsignedLong ulongVal = (UnsignedLong) key;
isDuplicate = keysSeen.contains(ulongVal.longValue());
}
}

if (!keysSeen.add(key)) {
if (isDuplicate) {
throw new LocalizedEvaluationException(
CelDuplicateKeyException.of(key), keyInterpretable.exprId());
}

Object val = values[i].eval(resolver, frame);

if (isOptional[i]) {
if (!(val instanceof Optional)) {
throw new IllegalArgumentException(
Expand Down
Loading