← board

wasm32: a const by-ref argument clones the string it indexes

Found once string literals became static handles (bug-a-wasm32-string-literals-are-heap-copies-so-a-const-table-stays-live): before that change, sysutils.Copy's source was a heap temp with rc=1, so the clone never happened. JSONParse('[1]') with FreeTree then leaked one block per array element. Native builds of the same probes stayed flat.

Resolution (2026-09-28)

Both wasm32 argument loops (the direct call and the indirect/virtual one) set WasmConstRefArg when the by-ref parameter is const. WasmEmitIndex then loads the handle from the slot instead of calling PXXStrUnique. A var argument still clones.