forked from M-Labs/artiq
compiler: do not permit iterating str values.
This currently breaks badly on UTF-8, and doesn't even return a value of a correct type.
This commit is contained in:
parent
4e7493843a
commit
ad2ee714c2
@ -183,7 +183,7 @@ class Inferencer(algorithm.Visitor):
|
||||
if builtins.is_bytes(collection.type) or builtins.is_bytearray(collection.type):
|
||||
self._unify(element.type, builtins.get_iterable_elt(collection.type),
|
||||
element.loc, None)
|
||||
elif builtins.is_iterable(collection.type):
|
||||
elif builtins.is_iterable(collection.type) and not builtins.is_str(collection.type):
|
||||
rhs_type = collection.type.find()
|
||||
rhs_wrapped_lhs_type = types.TMono(rhs_type.name, {"elt": element.type})
|
||||
self._unify(rhs_wrapped_lhs_type, rhs_type,
|
||||
|
5
artiq/test/lit/inferencer/error_str_iter.py
Normal file
5
artiq/test/lit/inferencer/error_str_iter.py
Normal file
@ -0,0 +1,5 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.inferencer +diag %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: type str is not iterable
|
||||
("a")[0]
|
Loading…
Reference in New Issue
Block a user