forked from M-Labs/artiq
Make binop coercion look through CoerceT nodes.
This fixes inference for "x = 1 + 1" after int monomorphization.
This commit is contained in:
parent
ebe243f8d9
commit
f417ef31a4
|
@ -4,7 +4,6 @@ typing information.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pythonparser import ast
|
from pythonparser import ast
|
||||||
from pythonparser.algorithm import Visitor as ASTVisitor
|
|
||||||
|
|
||||||
class commontyped(ast.commonloc):
|
class commontyped(ast.commonloc):
|
||||||
"""A mixin for typed AST nodes."""
|
"""A mixin for typed AST nodes."""
|
||||||
|
|
|
@ -183,7 +183,12 @@ class Inferencer(algorithm.Visitor):
|
||||||
|
|
||||||
def _coerce_numeric(self, nodes, map_return=lambda typ: typ):
|
def _coerce_numeric(self, nodes, map_return=lambda typ: typ):
|
||||||
# See https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex.
|
# See https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex.
|
||||||
node_types = [node.type for node in nodes]
|
node_types = []
|
||||||
|
for node in nodes:
|
||||||
|
if isinstance(node, asttyped.CoerceT):
|
||||||
|
node_types.append(node.expr.type)
|
||||||
|
else:
|
||||||
|
node_types.append(node.type)
|
||||||
if any(map(types.is_var, node_types)): # not enough info yet
|
if any(map(types.is_var, node_types)): # not enough info yet
|
||||||
return
|
return
|
||||||
elif not all(map(builtins.is_numeric, node_types)):
|
elif not all(map(builtins.is_numeric, node_types)):
|
||||||
|
|
Loading…
Reference in New Issue