Summary
Under perry compile, a freshly-allocated Float64Array reports typeof a === 'number' and method-property access like typeof a.sort === 'undefined'. Calling a.sort() throws TypeError: (number).sort is not a function. The element-wise data is correct (console.log prints the right values); only the type tag and method dispatch are broken.
Same shape as #157 / #269 / #578 (all closed) but on a different method-dispatch path — those handled the constructor / .at() / iteration-by-NaN-bits cases. This one is method dispatch on the typed array itself.
Found while running @perryts/redis's benchmark suite, where the latency aggregator sorts a Float64Array of per-op times.
Environment
- perry 0.5.772
- macOS 26.4 / Apple M1 Max
Minimal repro
// repro.ts
const a = new Float64Array(5);
for (let i = 0; i < 5; i++) a[i] = 5 - i;
console.log('a:', a); // Float64Array(5) [ 5, 4, 3, 2, 1 ]
console.log('typeof a:', typeof a); // 'number' ← expected 'object'
console.log('typeof a.sort:', typeof a.sort); // 'undefined' ← expected 'function'
a.sort(); // throws under AOT
console.log('sorted:', a);
$ perry compile repro.ts -o repro && ./repro
a: Float64Array(5) [ 5, 4, 3, 2, 1 ]
typeof a: number
typeof a.sort: undefined
TypeError: (number).sort is not a function
at <anonymous>
Bonus: copy-from-typed-array constructor returns empty
Same source file:
const b = new Float64Array(a);
console.log('b:', b, 'len:', b.length);
// Actual: Float64Array(0) [] len: 0
// Expected: Float64Array(5) [ 5, 4, 3, 2, 1 ] len: 5
This may be the same root cause (typeof a === 'number' means the constructor's typed-array branch isn't recognizing the input as a typed array) or it may be independent.
Impact
Anything aggregating numeric metrics in a Float64Array can't sort, slice, or copy it. Workaround for @perryts/redis: use number[] instead of Float64Array. Not a great answer for math-heavy code where typed arrays are the obvious choice.
Related (closed)
Summary
Under
perry compile, a freshly-allocatedFloat64Arrayreportstypeof a === 'number'and method-property access liketypeof a.sort === 'undefined'. Callinga.sort()throwsTypeError: (number).sort is not a function. The element-wise data is correct (console.log prints the right values); only the type tag and method dispatch are broken.Same shape as #157 / #269 / #578 (all closed) but on a different method-dispatch path — those handled the constructor /
.at()/ iteration-by-NaN-bits cases. This one is method dispatch on the typed array itself.Found while running
@perryts/redis's benchmark suite, where the latency aggregator sorts a Float64Array of per-op times.Environment
Minimal repro
Bonus: copy-from-typed-array constructor returns empty
Same source file:
This may be the same root cause (typeof a === 'number' means the constructor's typed-array branch isn't recognizing the input as a typed array) or it may be independent.
Impact
Anything aggregating numeric metrics in a Float64Array can't sort, slice, or copy it. Workaround for
@perryts/redis: usenumber[]instead ofFloat64Array. Not a great answer for math-heavy code where typed arrays are the obvious choice.Related (closed)
.at()returns undefined on typed arrays