You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[js-api] fromCharCodeArray polyfill treats the end index as a count #2342
The builtin takes (array, start, end) and reads [start, end). The polyfill instead treats the third argument as a count and reads [start, start + count).
To reproduce, save the following as repro.js in the repository root and run d8 repro.js with a GC-capable d8:
load("test/js-api/wasm-module-builder.js");load("test/js-api/js-string/polyfill.js");constarray=helperExports.createArrayMutI16(4);for(leti=0;i<4;i++){helperExports.arraySet(array,i,65+i);}print(polyfillImports.fromCharCodeArray(array,1,2));// Observed: BC// Expected: B
For this array containing ABCD, I observed:
start
end argument
Expected
Observed polyfill result
0
4
"ABCD"
"ABCD"
1
2
"B"
"BC"
1
1
""
"B"
3
4
"D"
WebAssembly.RuntimeError
2
1
WebAssembly.RuntimeError
"C"
I reproduced these polyfill results both directly and through an ordinary Wasm import, using unchanged upstream files. Environment: locally built d8 15.4.80.20, Ubuntu 24.04. I did not test the native builtin or run the full WPT suite.
The existing comparison uses (array, 0, length), where an end index and a count coincide, so it does not distinguish these conventions.
Would it make sense to align the polyfill with the specified [start, end) contract and extend the tests to cover nonzero starts, empty ranges, and reversed ranges?
changed the title [-]fromCharCodeArray polyfill treats the end index as a count[/-][+][js-api] fromCharCodeArray polyfill treats the end index as a count[/+]on Nov 23, 2026
Activity
[-]fromCharCodeArray polyfill treats the end index as a count[/-][+][js-api] fromCharCodeArray polyfill treats the end index as a count[/+]eqrion commentedon Nov 24, 2026
Thanks for the report, this should be fixed in #2348 now.