feat: infer generic arguments from expected results

This commit is contained in:
2026-10-30 12:53:11 +01:00
parent b1cc97cc77
commit c65f41db43
8 changed files with 626 additions and 37 deletions
+4 -1
View File
@@ -81,6 +81,7 @@ recompiles_specialized_calls_without_borrowing_previous_ir test {
` if (T == i16) return value else return value.missing
`}
`Box proc(T type) type { return struct { value T } }
`make_box proc($T type) Box(T) { return { value = 40 } }
`count proc() usize {
` result := 0
` while (result < 2) result = result + 1
@@ -267,7 +268,9 @@ recompiles_specialized_calls_without_borrowing_previous_ir test {
`main proc() i16 {
` if $(i16 != i16) { return $(i8(128)) }
` values :: $(data())
` box Box(i16) :: { value = identity(i16, values[0]) }
` box Box(i16) :: make_box()
` inferred i16 :: identity(40)
` if (inferred != box.value) return 0
` fixed Fixed(count()) :: { values = [box.value, 2] }
` same Fixed(2) :: fixed
` packet :: $(packet_data())