Bug 478617 - kwin scripting reports needing ';' or ',' in lines of good javascript code seen in the declaration 'async' as well as the 'await' operator.
Summary: kwin scripting reports needing ';' or ',' in lines of good javascript code se...
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: scripts (other bugs)
Version First Reported In: 5.27.10
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-16 20:47 UTC by Sjoerd
Modified: 2023-12-23 22:20 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sjoerd 2023-12-16 20:47:05 UTC
SUMMARY
kwin scripting despite having support and working with promise and thenable objects under kwin. Does not seem to recognise the operator 'await' or 'async' declarations which are features of ES6 along with the mentioned thenables and the class syntax. Both of which I use in my kwin script. Instead of just working I get syntax errors in the console saying that the specific line is missing a semicolon or comma.

STEPS TO REPRODUCE
1. 
type something like: 
```
async function() {
    
}
```
or like:
```
const variable = await Promise.race([myFunc(500), myAsyncFunc()]);
```
in the plasmainteractive console.
2. 
Open up a journalctl listener with:
```
journalctl -f QT_CATEGORY=js QT_CATEGORY=kwin_scripting
```
3.
And execute the scripting using the kwin environment setting in the interactive console.

OBSERVED RESULT
Outputs these errors in the console:
```
Dec 16 20:48:52 TRKY2 kwin_x11[1095]: kwin_scripting: /home/s/.local/share/plasma-interactiveconsole/interactiveconsoleautosave.js:65: error: Expected token `,'
Dec 16 20:49:13 TRKY2 kwin_x11[1095]: kwin_scripting: /home/s/.local/share/plasma-interactiveconsole/interactiveconsoleautosave.js:60: error: Expected token `;'
```
EXPECTED RESULT
Executing the code asynchronously with expected behavior.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.113.0
Qt Version: 5.15.11
Kernel Version: 6.6.7-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1080/PCIe/SSE2
Manufacturer: Gigabyte Technology Co., Ltd.
Product Name: X570 AORUS ELITE
System Version: -CF

ADDITIONAL INFORMATION
bug report 447922 seems to be the same issue however it is slightly different as lambda functions do seem to work for me and it doesnt mention 'await'
Comment 1 Nicolas Fella 2023-12-16 21:34:27 UTC
QJSEngine, which KWin uses for the script evaluation, doesn't support async/await. See https://bugreports.qt.io/browse/QTBUG-58620