From ca74f70061f65678905f98aeaf94a9373abab83f Mon Sep 17 00:00:00 2001 From: Sean Huh Date: Thu, 10 Sep 2026 23:23:06 +0000 Subject: [PATCH 1/2] Add conformance tests around type decaying --- .../simple/testdata/type_deduction.textproto | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/simple/testdata/type_deduction.textproto b/tests/simple/testdata/type_deduction.textproto index 1a0e2611..c69eb665 100644 --- a/tests/simple/testdata/type_deduction.textproto +++ b/tests/simple/testdata/type_deduction.textproto @@ -951,3 +951,74 @@ section { } } } + +section { + name: "type_decay" + description: "Tests for type decay / least-upper-bound generalization of types." + test { + name: "type_list_decay" + expr: "[int, bool, double]" + typed_result { + result { + list_value { + values { + type_value: "int" + } + values { + type_value: "bool" + } + values { + type_value: "double" + } + } + } + deduced_type { + list_type { + elem_type { + type { + dyn {} + } + } + } + } + } + } + test { + name: "type_ternary_decay" + expr: "true ? type(1) : type(1u)" + typed_result { + result { + type_value: "int" + } + deduced_type { + type { + dyn {} + } + } + } + } + test { + name: "type_free_param_list_decay" + description: "Type decay for list literal containing a free type parameter in TypeType and a concrete type." + expr: "[type([]), int]" + typed_result { + result { + list_value { + values { + type_value: "list" + } + values { + type_value: "int" + } + } + } + deduced_type { + list_type { + elem_type { + dyn {} + } + } + } + } + } +} From d4c6ed1bfce0016414a28bc9831e581126a2302d Mon Sep 17 00:00:00 2001 From: Sean Huh Date: Fri, 11 Sep 2026 00:03:17 +0000 Subject: [PATCH 2/2] Add more tests --- .../simple/testdata/type_deduction.textproto | 80 ++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/tests/simple/testdata/type_deduction.textproto b/tests/simple/testdata/type_deduction.textproto index c69eb665..f6cf94ca 100644 --- a/tests/simple/testdata/type_deduction.textproto +++ b/tests/simple/testdata/type_deduction.textproto @@ -954,7 +954,7 @@ section { section { name: "type_decay" - description: "Tests for type decay / least-upper-bound generalization of types." + description: "Tests for type decay / least-upper-bound generalization of type values." test { name: "type_list_decay" expr: "[int, bool, double]" @@ -999,7 +999,7 @@ section { } test { name: "type_free_param_list_decay" - description: "Type decay for list literal containing a free type parameter in TypeType and a concrete type." + description: "Type decay for list literal containing a free type parameter in a type value and a concrete type." expr: "[type([]), int]" typed_result { result { @@ -1021,4 +1021,80 @@ section { } } } + test { + name: "type_nested_list_decay" + description: "Type decay for nested list literal with differing type values." + expr: "[[type(1)], [type(1u)]]" + typed_result { + result { + list_value { + values { + list_value { + values { + type_value: "int" + } + } + } + values { + list_value { + values { + type_value: "uint" + } + } + } + } + } + deduced_type { + list_type { + elem_type { + list_type { + elem_type { + type { + dyn {} + } + } + } + } + } + } + } + } + test { + name: "type_free_param_list_concat" + description: "Type deduction for concatenated lists containing free type parameters in type values." + expr: "([] + [[type(1)]]) + [[type([])]]" + typed_result { + result { + list_value { + values { + list_value { + values { + type_value: "int" + } + } + } + values { + list_value { + values { + type_value: "list" + } + } + } + } + } + deduced_type { + list_type { + elem_type { + list_type { + elem_type { + type { + dyn {} + } + } + } + } + } + } + } + } }