Describe the bug
In Vim9 script, we cannot surround a ternary operator with parentheses.
To Reproduce
Run this shell command:
vim -Nu NONE +'vim9 echo (a == 0 ? 0 : 0)'
E15 is raised:
E15: Invalid expression: "= 0 ? 0 : 0)"
Expected behavior
No error is raised.
Environment
Additional context
Regression introduced in 8.2.3056.
The previous code is useless. Here, is a more useful one:
const FLAG2ARG: dict<string> = { S: '<script>', b: '<buffer>', e: '<expr>', n: '<nowait>', s: '<silent>', u: '<unique>', } def MapMeta( key: string, rhs: string, mode: string, flags: string ) exe (mode != '!' ? mode : '') .. (flags =~ 'r' ? 'map' : 'noremap') .. (mode == '!' ? '!' : '') .. ' ' .. MapArguments(flags) .. ' ' .. '<m-' .. key .. '>' .. ' ' .. rhs enddef def MapArguments(flags: string): string return split(flags, '\zs') ->map((_, v: string): string => get(FLAG2ARG, v, '')) ->join() enddef defcompile
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
No error is raised.
Actually, an error would be raised even if the issue was fixed, because a is undefined. Here is a new MWE:
vim -Nu NONE +'vim9 var a = 0 | vim9 echo (a == 0 ? 0 : 0)'
The issue was fixed for the == comparison operator, but it persists for =~:
vim -Nu NONE +'vim9 var a = "" | vim9 echo (a =~ "" ? 0 : 0)'
E15: Invalid expression: "~ "" ? 0 : 0)"