diff --git a/src/plugins/local-llm-rename/visit-all-identifiers.test.ts b/src/plugins/local-llm-rename/visit-all-identifiers.test.ts index e821218..a1d3a9a 100644 --- a/src/plugins/local-llm-rename/visit-all-identifiers.test.ts +++ b/src/plugins/local-llm-rename/visit-all-identifiers.test.ts @@ -298,3 +298,20 @@ const bar = 2; `.trim() ); }); + +test("should not craash to 'arguments' assigning", async () => { + const code = ` +function foo() { + arguments = '??'; +} +`.trim(); + const result = await visitAllIdentifiers(code, async () => "foobar", 200); + assert.equal( + result, + ` +function foobar() { + arguments = '??'; +} + `.trim() + ); +}); diff --git a/src/plugins/local-llm-rename/visit-all-identifiers.ts b/src/plugins/local-llm-rename/visit-all-identifiers.ts index bcd434c..f50024e 100644 --- a/src/plugins/local-llm-rename/visit-all-identifiers.ts +++ b/src/plugins/local-llm-rename/visit-all-identifiers.ts @@ -16,7 +16,7 @@ export async function visitAllIdentifiers( contextWindowSize: number, onProgress?: (percentageDone: number) => void ) { - const ast = await parseAsync(code); + const ast = await parseAsync(code, { sourceType: "script" }); const renames = new Set(); const visited = new Set();