Skip to content

Commit 1126ef1

Browse files
authoredSep 27, 2023
fix: StaticArray#concat link child to incorrect parent (#2746)
1 parent 321ed3d commit 1126ef1

File tree

4 files changed

+1976
-1569
lines changed

4 files changed

+1976
-1569
lines changed
 

‎std/assembly/staticarray.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ export class StaticArray<T> {
214214
for (let offset: usize = 0; offset < sourceSize; offset += sizeof<T>()) {
215215
let ref = load<usize>(thisStart + offset);
216216
store<usize>(outStart + offset, ref);
217-
__link(outStart, ref, true);
217+
__link(changetype<usize>(out), ref, true);
218218
}
219219
outStart += sourceSize;
220220
let otherSize = <usize>otherLen << alignof<T>();
221221
for (let offset: usize = 0; offset < otherSize; offset += sizeof<T>()) {
222222
let ref = load<usize>(otherStart + offset);
223223
store<usize>(outStart + offset, ref);
224-
__link(outStart, ref, true);
224+
__link(changetype<usize>(out), ref, true);
225225
}
226226
} else {
227227
memory.copy(outStart, thisStart, sourceSize);

‎tests/compiler/std/staticarray.debug.wat

+1,062-852
Large diffs are not rendered by default.

‎tests/compiler/std/staticarray.release.wat

+907-715
Large diffs are not rendered by default.

‎tests/compiler/std/staticarray.ts

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ arr4 = changetype<StaticArray<Ref>>(0);
7070
result = source.concat<StaticArray<i32>>([]);
7171
assert(result.length == source.length);
7272
}
73+
{
74+
let source: StaticArray<string> = ["1", "2"];
75+
let result = source.concat<StaticArray<string>>(["3"]);
76+
assert(result.length == 3);
77+
}
7378

7479
// slice
7580
{

0 commit comments

Comments
 (0)
Please sign in to comment.