Fix insert/delete for JS (#8915)

Fixes #8914
This commit is contained in:
LemonBoy
2018-09-08 10:38:18 +02:00
committed by Andreas Rumpf
parent 91b37311d9
commit 3f16711254
2 changed files with 14 additions and 2 deletions

View File

@@ -1552,7 +1552,7 @@ proc delete*[T](x: var seq[T], i: Natural) {.noSideEffect.} =
defaultImpl()
else:
when defined(js):
{.emit: "`x`[`x`_Idx].splice(`i`, 1);".}
{.emit: "`x`.splice(`i`, 1);".}
else:
defaultImpl()
@@ -1574,7 +1574,7 @@ proc insert*[T](x: var seq[T], item: T, i = 0.Natural) {.noSideEffect.} =
else:
when defined(js):
var it : T
{.emit: "`x`[`x`_Idx].splice(`i`, 0, `it`);".}
{.emit: "`x`.splice(`i`, 0, `it`);".}
else:
defaultImpl()
x[i] = item

12
tests/js/t8914.nim Normal file
View File

@@ -0,0 +1,12 @@
discard """
output: '''
@[42]
@[24, 42]
'''
"""
var x = @[42,4242]
x.delete(1)
echo x
x.insert(24)
echo x