-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.4.2
-
None
-
package qt6-declarative-6.4.2-1 from Arch Linux repository
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
| For Gerrit Dashboard: QTBUG-109880 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 576268,6 | QJSEngine: Disable tail calls for GeneratorFunction/Method | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
| 577169,4 | QJSEngine: Disable tail calls for GeneratorFunction/Method | 6.8 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
| 577401,5 | QJSEngine: Disable tail calls for GeneratorFunction/Method | 6.7 | qt/qtdeclarative | Status: MERGED | +2 | +1 |
| 580753,2 | QJSEngine: Disable tail calls for GeneratorFunction/Method | tqtc/lts-6.5 | qt/tqtc-qtdeclarative | Status: MERGED | +2 | 0 |