Skip to content

Commit 252372e

Browse files
authored
Add typecheck tests for edge cases with free type parameters (#463)
Add test cases for type vars in comprehensions.
1 parent 350d5e2 commit 252372e

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/simple/testdata/type_deduction.textproto

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,56 @@ section {
320320
}
321321
}
322322
}
323+
test {
324+
name: "comprehension_type_var_aliasing"
325+
expr: "msg.repeated_nested_message.map(x, x).map(y, y.bb)"
326+
check_only: true
327+
type_env {
328+
name: "msg"
329+
ident {
330+
type {
331+
message_type: "cel.expr.conformance.proto3.TestAllTypes"
332+
}
333+
}
334+
}
335+
typed_result {
336+
deduced_type {
337+
list_type {
338+
elem_type {
339+
primitive: INT64
340+
}
341+
}
342+
}
343+
}
344+
}
345+
test {
346+
name: "overload_type_var_aliasing"
347+
expr: "([] + msg.repeated_nested_message + [])[0].bb"
348+
check_only: true
349+
type_env {
350+
name: "msg"
351+
ident {
352+
type {
353+
message_type: "cel.expr.conformance.proto3.TestAllTypes"
354+
}
355+
}
356+
}
357+
typed_result {
358+
deduced_type {
359+
primitive: INT64
360+
}
361+
}
362+
}
363+
test {
364+
name: "unconstrained_type_var_as_dyn"
365+
expr: "([].map(x,x))[0].foo"
366+
check_only: true
367+
typed_result {
368+
deduced_type {
369+
dyn {}
370+
}
371+
}
372+
}
323373
test {
324374
name: "list_parameters_do_not_unify"
325375
expr: "[msg.single_int64_wrapper, msg.single_string_wrapper]"

0 commit comments

Comments
 (0)