Skip to content

Strict mode violation in generated code - 'arguments' used as parameter name #7162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mununki opened this issue Nov 19, 2024 · 0 comments · Fixed by #7163
Closed

Strict mode violation in generated code - 'arguments' used as parameter name #7162

mununki opened this issue Nov 19, 2024 · 0 comments · Fixed by #7163
Assignees
Labels

Comments

@mununki
Copy link
Member

mununki commented Nov 19, 2024

When compiling with ReScript v12.0.0-alpha.4, the compiler generates code that violates JavaScript strict mode by using 'arguments' as a parameter name. This causes runtime errors when the generated .mjs files are executed.

Reproduction:

  1. Using [email protected]
  2. Generated code in RescriptRelay.mjs contains function parameter named 'arguments'
  3. This leads to a strict mode violation error:
    "'eval' and 'arguments' cannot be used as a binding identifier in strict mode"
Import trace for requested module:
./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/rescript-relay/src/RescriptRelay.mjs
./src/App.mjs
   automatically enabled Fast Refresh for 2 custom loaders
 ⨯ ./node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/rescript-relay/src/RescriptRelay.mjs
Error: 
  × 'eval' and 'arguments' cannot be used as a binding identifier in strict mode
    ╭─[/Users/woonki/GitHub/gl/farmmoa-web2/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/rescript-relay/src/RescriptRelay.mjs:31:1]
 31 │   
 32 │ }
 33 │ 
 34 │ function getLinkedRecords(t, name, arguments) {
    ·                                    ─────────
 35 │   return optArrayOfNullableToOptArrayOfOpt(Primitive_option.fromNullable(t.getLinkedRecords(name, arguments)));
 36 │ }
    ╰────

Caused by:
    Syntax Error

This needs to be fixed in the compiler to use a different parameter name that doesn't conflict with JavaScript strict mode reserved words.

@cometkim cometkim self-assigned this Nov 19, 2024
@cometkim cometkim added the bug label Nov 19, 2024
cometkim added a commit to cometkim/rescript that referenced this issue Nov 19, 2024
cometkim added a commit that referenced this issue Nov 20, 2024
* Fix `arguments` and `eval` mangling

Fixed #7162

* add changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants