Skip to content

Commit

Permalink
Merge pull request #252 from jehna/fix/arguments-crash
Browse files Browse the repository at this point in the history
Fix strict mode crashing on arguments assign
  • Loading branch information
jehna authored Dec 16, 2024
2 parents 9c633db + e39a616 commit de64ca0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/plugins/local-llm-rename/visit-all-identifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
});
2 changes: 1 addition & 1 deletion src/plugins/local-llm-rename/visit-all-identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
const visited = new Set<string>();

Expand Down

0 comments on commit de64ca0

Please sign in to comment.