The follow code performs correctly when not using the -e6 parameter to Transcrypt, but fails when using -e6:
x = __new__(Int8Array(2))
x[0] = 3
x[1] = 2
for i in x:
print(i)
When run without -e6, the above code produces two lines of output, 3 and 2. With -e6 enabled, nothing is printed. While this bug is annoying, it might be a bit worse that no error is given when trying to iterate something non-iterable. This is a bug I ran into when trying to switch to using -e6, and it was quite hard to track down where the problem was coming from without any errors for not being able to iterate.
Int8Array defines a length and index-access, and a Symbol.iterator property for standard ES6 iterator access. This can be seen with the following code in a node.js console:
> let x = new Int8Array(2)
> x[0] = 3
> x[1] = 2
> for (let i of x) { console.log(i) }
3
2
I believe this is due to Transcrypt allowing for JavaScript generators, but not "iterables". I don't know too much about the internals of JavaScript nor Transcrypt, but I believe this could be fixed by checking for a Symbol.iterator property in py_iter?
In any case, I hope this information proves useful in improving Transcrypt.
The follow code performs correctly when not using the
-e6parameter to Transcrypt, but fails when using-e6:When run without
-e6, the above code produces two lines of output,3and2. With-e6enabled, nothing is printed. While this bug is annoying, it might be a bit worse that no error is given when trying to iterate something non-iterable. This is a bug I ran into when trying to switch to using-e6, and it was quite hard to track down where the problem was coming from without any errors for not being able to iterate.Int8Array defines a length and index-access, and a
Symbol.iteratorproperty for standard ES6 iterator access. This can be seen with the following code in a node.js console:I believe this is due to Transcrypt allowing for JavaScript generators, but not "iterables". I don't know too much about the internals of JavaScript nor Transcrypt, but I believe this could be fixed by checking for a
Symbol.iteratorproperty inpy_iter?In any case, I hope this information proves useful in improving Transcrypt.