forked from M-Labs/artiq
1
0
Fork 0

Don't error out in inferencer if builtin arguments have polymorphic types.

This commit is contained in:
whitequark 2015-07-04 04:27:15 +03:00
parent 16432d2652
commit 4785f0a2de
1 changed files with 17 additions and 2 deletions

View File

@ -412,9 +412,13 @@ class Inferencer(algorithm.Visitor):
if len(node.args) == 0 and len(node.keywords) == 0: if len(node.args) == 0 and len(node.keywords) == 0:
pass # 0 pass # 0
elif len(node.args) == 1 and len(node.keywords) == 0 and \
types.is_var(node.args[0].type):
pass # undetermined yet
elif len(node.args) == 1 and len(node.keywords) == 0 and \ elif len(node.args) == 1 and len(node.keywords) == 0 and \
builtins.is_numeric(node.args[0].type): builtins.is_numeric(node.args[0].type):
pass self._unify(node.type, builtins.TInt(),
node.loc, None)
elif len(node.args) == 1 and len(node.keywords) == 1 and \ elif len(node.args) == 1 and len(node.keywords) == 1 and \
builtins.is_numeric(node.args[0].type) and \ builtins.is_numeric(node.args[0].type) and \
node.keywords[0].arg == 'width': node.keywords[0].arg == 'width':
@ -441,6 +445,9 @@ class Inferencer(algorithm.Visitor):
if len(node.args) == 0 and len(node.keywords) == 0: if len(node.args) == 0 and len(node.keywords) == 0:
pass # 0.0 pass # 0.0
elif len(node.args) == 1 and len(node.keywords) == 0 and \
types.is_var(node.args[0].type):
pass # undetermined yet
elif len(node.args) == 1 and len(node.keywords) == 0 and \ elif len(node.args) == 1 and len(node.keywords) == 0 and \
builtins.is_numeric(node.args[0].type): builtins.is_numeric(node.args[0].type):
pass pass
@ -462,6 +469,8 @@ class Inferencer(algorithm.Visitor):
if builtins.is_iterable(arg.type): if builtins.is_iterable(arg.type):
pass pass
elif types.is_var(arg.type):
pass # undetermined yet
else: else:
note = diagnostic.Diagnostic("note", note = diagnostic.Diagnostic("note",
"this expression has type {type}", "this expression has type {type}",
@ -489,7 +498,11 @@ class Inferencer(algorithm.Visitor):
self._unify(arg.type, range_tvar, self._unify(arg.type, range_tvar,
arg.loc, None) arg.loc, None)
if not builtins.is_numeric(arg.type): if builtins.is_numeric(arg.type):
pass
elif types.is_var(arg.type):
pass # undetermined yet
else:
note = diagnostic.Diagnostic("note", note = diagnostic.Diagnostic("note",
"this expression has type {type}", "this expression has type {type}",
{"type": types.TypePrinter().name(arg.type)}, {"type": types.TypePrinter().name(arg.type)},
@ -514,6 +527,8 @@ class Inferencer(algorithm.Visitor):
if builtins.is_iterable(arg.type): if builtins.is_iterable(arg.type):
pass pass
elif types.is_var(arg.type):
pass # undetermined yet
else: else:
note = diagnostic.Diagnostic("note", note = diagnostic.Diagnostic("note",
"this expression has type {type}", "this expression has type {type}",