diff --git a/as/testcase/useUtf8Transform.ts b/as/testcase/useUtf8Transform.ts index 68a13ee..59a438a 100644 --- a/as/testcase/useUtf8Transform.ts +++ b/as/testcase/useUtf8Transform.ts @@ -22,7 +22,12 @@ export const obj: C2 = { export const arr: C1[] = [new C1(utf8.build("test2"), 4)]; +function foo(str: utf8.ConstStr): void { + str; +} + export function _start(): void { const str = utf8.build("test3"); log(str.addr, str.size); + foo(utf8.build("test4")); } diff --git a/package.json b/package.json index 193fb46..487bbfb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@schleifner/assemblyscript-transform", - "version": "0.1.0", + "version": "0.1.1", "author": "", "description": "const utf8 string literal in AssemblyScript", "type": "module", diff --git a/tests/transform.test.ts b/tests/transform.test.ts index e500571..821edd2 100644 --- a/tests/transform.test.ts +++ b/tests/transform.test.ts @@ -36,6 +36,7 @@ test("transform convert utf8 success", () => { expect(watContent).toContain("test1"); expect(watContent).toContain("test2"); expect(watContent).toContain("test3"); + expect(watContent).toContain("test4"); }); test("transform not string literal", () => { diff --git a/transform/transformBuildUtf8ConstStr.mts b/transform/transformBuildUtf8ConstStr.mts index 7cbffc1..e6e85d3 100644 --- a/transform/transformBuildUtf8ConstStr.mts +++ b/transform/transformBuildUtf8ConstStr.mts @@ -319,8 +319,12 @@ export default class TransformBuildUtf8ConstStr extends Transform { if (this.isUtf8BuildCall(leftExpression, propertyAccessExpression)) { this.handleUtf8BuildCall(node, propertyAccessExpression); + return; } } + for (const arg of node.args) { + this.visitNode(arg); + } } private isUtf8BuildCall(leftExpression: Node, propertyAccessExpression: PropertyAccessExpression): boolean {