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):
|
if builtins.is_bytes(collection.type) or builtins.is_bytearray(collection.type):
|
||||||
self._unify(element.type, builtins.get_iterable_elt(collection.type),
|
self._unify(element.type, builtins.get_iterable_elt(collection.type),
|
||||||
element.loc, None)
|
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_type = collection.type.find()
|
||||||
rhs_wrapped_lhs_type = types.TMono(rhs_type.name, {"elt": element.type})
|
rhs_wrapped_lhs_type = types.TMono(rhs_type.name, {"elt": element.type})
|
||||||
self._unify(rhs_wrapped_lhs_type, rhs_type,
|
self._unify(rhs_wrapped_lhs_type, rhs_type,
|
||||||
|
|
|
@ -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