Skip to content

Commit a18555e

Browse files
Bugfix: can't transform utf8 in function parameter #2
2 parents d4dc4e6 + e948958 commit a18555e

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

as/testcase/useUtf8Transform.ts

+5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ export const obj: C2 = {
2222

2323
export const arr: C1[] = [new C1(utf8.build("test2"), 4)];
2424

25+
function foo(str: utf8.ConstStr): void {
26+
str;
27+
}
28+
2529
export function _start(): void {
2630
const str = utf8.build("test3");
2731
log(str.addr, str.size);
32+
foo(utf8.build("test4"));
2833
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@schleifner/assemblyscript-transform",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"author": "",
55
"description": "const utf8 string literal in AssemblyScript",
66
"type": "module",

tests/transform.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ test("transform convert utf8 success", () => {
3636
expect(watContent).toContain("test1");
3737
expect(watContent).toContain("test2");
3838
expect(watContent).toContain("test3");
39+
expect(watContent).toContain("test4");
3940
});
4041

4142
test("transform not string literal", () => {

transform/transformBuildUtf8ConstStr.mts

+4
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,12 @@ export default class TransformBuildUtf8ConstStr extends Transform {
319319

320320
if (this.isUtf8BuildCall(leftExpression, propertyAccessExpression)) {
321321
this.handleUtf8BuildCall(node, propertyAccessExpression);
322+
return;
322323
}
323324
}
325+
for (const arg of node.args) {
326+
this.visitNode(arg);
327+
}
324328
}
325329

326330
private isUtf8BuildCall(leftExpression: Node, propertyAccessExpression: PropertyAccessExpression): boolean {

0 commit comments

Comments
 (0)