Skip to content

Commit 0d2d823

Browse files
committed
Unfortunate workaround
1 parent 831651c commit 0d2d823

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

mypyc/irbuild/mapper.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,21 @@ def fdef_to_sig(self, fdef: FuncDef) -> FuncSignature:
133133
else:
134134
ret = object_rprimitive
135135

136-
args = [RuntimeArg(arg.variable.name, arg_type, arg.kind)
137-
for arg, arg_type in zip(fdef.arguments, arg_types)]
136+
# mypyc FuncSignatures (unlike mypy types) want to have a name
137+
# present even when the argument is position only, since it is
138+
# the sole way that FuncDecl arguments are tracked. This is
139+
# generally fine except in some cases (like for computing
140+
# init_sig) we need to produce FuncSignatures from a
141+
# deserialized FuncDef that lacks arguments. We won't ever
142+
# need to use those inside of a FuncIR, so we just make up
143+
# some crap.
144+
if hasattr(fdef, 'arguments'):
145+
arg_names = [arg.variable.name for arg in fdef.arguments]
146+
else:
147+
arg_names = [name or '' for name in fdef.arg_names]
148+
149+
args = [RuntimeArg(arg_name, arg_type, arg_kind)
150+
for arg_name, arg_kind, arg_type in zip(arg_names, fdef.arg_kinds, arg_types)]
138151

139152
# We force certain dunder methods to return objects to support letting them
140153
# return NotImplemented. It also avoids some pointless boxing and unboxing,

0 commit comments

Comments
 (0)