Skip to content

Commit

Permalink
Fixed translation of variable size tuple type literals
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoeilers committed Feb 29, 2024
1 parent 3f6918c commit d88b607
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/nagini_translation/lib/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,20 @@ def get_target(node: ast.AST,
if isinstance(possible_class, PythonType):
type_class = possible_class
if type_class:
fixed_size = True
# Look up the type arguments. Also consider string arguments.
if isinstance(node.slice.value, ast.Tuple):
args = [get_target(arg, containers, container, True)
for arg in node.slice.value.elts]
if len(node.slice.value.elts) == 2 and isinstance(node.slice.value.elts[1], ast.Ellipsis):
args = [get_target(node.slice.value.elts[0], containers, container, True)]
fixed_size = False
else:
args = [get_target(arg, containers, container, True)
for arg in node.slice.value.elts]
else:
args = [get_target(node.slice.value, containers, container, True)]
return GenericType(type_class, args)
res = GenericType(type_class, args)
res.exact_length = fixed_size
return res
if node.value.id == 'Optional':
option = get_target(node.slice.value, containers, container, True)
return OptionalType(option)
Expand Down

0 comments on commit d88b607

Please sign in to comment.