Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.4.2
-
None
-
package qt6-declarative-6.4.2-1 from Arch Linux repository
Description
See the example Javascript code below. In the code, the method `generatorZero` should return a Generator object, but it instead returns `undefined`.
If you first store the Generator in a variable before returning it, it works as expected. This is demonstrated with the method `generatorZeroWorkaround`.
class Class { *generatorFrom(start) { while (true) { yield start++; } } generatorZero() { return this.generatorFrom(0); } generatorZeroWorkaround() { const g = this.generatorFrom(0); return g; } } const c = new Class(); print(c.generatorZero()); // undefined print(c.generatorZeroWorkaround()); // [object Generator]
Steps to reproduce:
- Put the above code in a file named bug.js
- In the same directory create a file named bug.qml with the following contents:
import QtQuick 6.0 import "bug.js" as Logic Item {}
- Run `qml bug.qml` and observe the output of the command