Skip to content

Commit 958b356

Browse files
davidwzhaoclaude
andcommitted
Fix Call.target_type() for variadic builtin.tuple
builtin.tuple is registered as variadic (arity -1), so make_builtin gives it an empty param list and the generic type-variable matching can't resolve the return type T. Add a special case that infers TupleType directly from the argument types, matching what _infer_type already does in the parser. Without this, IfElse nodes wrapping tuple constructs were typed as interface{} in Go, causing a compile error when the function's declared return type is []interface{}. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent dfed824 commit 958b356

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

meta/src/meta/target.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ def __post_init__(self):
345345
def target_type(self) -> "TargetType":
346346
if isinstance(self.func, (ParseNonterminal, PrintNonterminal)):
347347
return self.func.target_type()
348+
# builtin.tuple is variadic; infer TupleType from the argument types directly.
349+
if isinstance(self.func, Builtin) and self.func.name == "tuple":
350+
return TupleType(tuple(a.target_type() for a in self.args))
348351
func_type = self.func.target_type()
349352
if isinstance(func_type, FunctionType):
350353
# Match parameter types against argument types to build type variable mapping

0 commit comments

Comments
 (0)