mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
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:
@@ -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"
|
||||
|
||||
@@ -593,12 +593,9 @@ proc nimCopy(dest, src: JSRef, ti: PNimType): JSRef =
|
||||
`result` = null;
|
||||
}
|
||||
else {
|
||||
if (`dest` === null || `dest` === undefined) {
|
||||
if (`dest` === null || `dest` === undefined || `dest`.length != `src`.length) {
|
||||
`dest` = new Array(`src`.length);
|
||||
}
|
||||
else {
|
||||
`dest`.length = `src`.length;
|
||||
}
|
||||
`result` = `dest`;
|
||||
for (var i = 0; i < `src`.length; ++i) {
|
||||
`result`[i] = nimCopy(`result`[i], `src`[i], `ti`.base);
|
||||
|
||||
Reference in New Issue
Block a user