From 5756cfcebcbd1739677d02e4b29de4ab0d1eff60 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 16 Jul 2015 15:35:46 +0300 Subject: [PATCH] Correctly infer type of list(iterable). --- artiq/compiler/transforms/inferencer.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index 9e927d60f..a8afa8a9a 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -534,7 +534,20 @@ class Inferencer(algorithm.Visitor): arg, = node.args if builtins.is_iterable(arg.type): - pass + def makenotes(printer, typea, typeb, loca, locb): + return [ + diagnostic.Diagnostic("note", + "iterator returning elements of type {typea}", + {"typea": printer.name(typea)}, + loca), + diagnostic.Diagnostic("note", + "iterator returning elements of type {typeb}", + {"typeb": printer.name(typeb)}, + locb) + ] + self._unify(node.type.find().params["elt"], + arg.type.find().params["elt"], + node.loc, arg.loc, makenotes=makenotes) elif types.is_var(arg.type): pass # undetermined yet else: