fixes #26152; JS regression: dockhack.js is invalid

This commit is contained in:
ringabout
2026-08-31 22:50:58 +08:00
parent dcec8e1cd1
commit f3b04ccd87
2 changed files with 17 additions and 6 deletions

View File

@@ -49,6 +49,13 @@ proc bar(s: var seq[int], a: int) =
s.bar(5)
doAssert(s == @[123, 1])
# Imported JavaScript patterns must receive the underlying array, not the
# `{base, off, len}` view used for regular `var openArray` parameters.
proc jsSort[T](x: var openArray[T], cmp: proc(a, b: T): int) {.importcpp: "#.sort(#)", nodecl.}
var sorted = @[2, 1]
sorted.jsSort(proc(a, b: int): int = a - b)
doAssert(sorted == @[1, 2])
import tables
block: # Test get addr of byvar return value
var t = initTable[string, int]()