summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-04-03 22:59:35 +0800
committerGitHub <noreply@github.com>2024-04-03 16:59:35 +0200
commit9e1b170a09d2228214807a8c01fe37b874f77d58 (patch)
tree72acf23b56a05eabfd21e52f740e2b4505eb3f8b /lib
parentdee55f587f4e3cfc8ffe28e4a41eba9c8ed7f2f8 (diff)
downloadNim-9e1b170a09d2228214807a8c01fe37b874f77d58.tar.gz
fixes #16771; lower `swap` for JS backend (#23473)
fixes #16771

follow up https://github.com/nim-lang/Nim/pull/16536

Ideally it should be handled in the IR part in the future

I have also checked the double evaluation of `swap` in the JS runtime
https://github.com/nim-lang/Nim/issues/16779, that might be solved by a
copy flag or something. Well, it should be best solved in the IR so that
it doesn't bother backends anymore.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/collections/lists.nim4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim
index 9b89fe9f8..6b88747ef 100644
--- a/lib/pure/collections/lists.nim
+++ b/lib/pure/collections/lists.nim
@@ -384,9 +384,7 @@ proc prependMoved*[T: SomeLinkedList](a, b: var T) {.since: (1, 5, 1).} =
     assert s == [0, 1, 0, 1, 0, 1]
 
   b.addMoved(a)
-  when defined(js): # XXX: swap broken in js; bug #16771
-    (b, a) = (a, b)
-  else: swap a, b
+  swap a, b
 
 proc add*[T](L: var SinglyLinkedList[T], n: SinglyLinkedNode[T]) {.inline.} =
   ## Appends (adds to the end) a node `n` to `L`. Efficiency: O(1).