fix for js strict mode (#18799)
* Assignments, which would accidentally create global variables, instead throw an error in strict mode * Assignment to a getter-only property Co-authored-by: Sven Keller <s.keller@cortona.de>
This commit is contained in:
parent
686096a912
commit
3c2edd142b
2 changed files with 2 additions and 5 deletions
|
|
@ -1769,7 +1769,7 @@ proc genVarInit(p: PProc, v: PSym, n: PNode) =
|
|||
inc p.extraIndent
|
||||
elif useGlobalPragmas:
|
||||
lineF(p, "if (globalThis.$1 === undefined) {$n", varName)
|
||||
varCode = $varName
|
||||
varCode = "globalThis." & $varName
|
||||
inc p.extraIndent
|
||||
else:
|
||||
varCode = "var $2"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue