From 4785f0a2de838b6b0b9178154a2c0e959cfd63d9 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 4 Jul 2015 04:27:15 +0300 Subject: [PATCH] Don't error out in inferencer if builtin arguments have polymorphic types. --- artiq/compiler/transforms/inferencer.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index 6694b6129..37de32532 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -412,9 +412,13 @@ class Inferencer(algorithm.Visitor): if len(node.args) == 0 and len(node.keywords) == 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 \ 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 \ builtins.is_numeric(node.args[0].type) and \ node.keywords[0].arg == 'width': @@ -441,6 +445,9 @@ class Inferencer(algorithm.Visitor): if len(node.args) == 0 and len(node.keywords) == 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 \ builtins.is_numeric(node.args[0].type): pass @@ -462,6 +469,8 @@ class Inferencer(algorithm.Visitor): if builtins.is_iterable(arg.type): pass + elif types.is_var(arg.type): + pass # undetermined yet else: note = diagnostic.Diagnostic("note", "this expression has type {type}", @@ -489,7 +498,11 @@ class Inferencer(algorithm.Visitor): self._unify(arg.type, range_tvar, 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", "this expression has type {type}", {"type": types.TypePrinter().name(arg.type)}, @@ -514,6 +527,8 @@ class Inferencer(algorithm.Visitor): if builtins.is_iterable(arg.type): pass + elif types.is_var(arg.type): + pass # undetermined yet else: note = diagnostic.Diagnostic("note", "this expression has type {type}",