Skip to content

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

Closed
@mununki

Description

@mununki

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 rescript-relay@3.0.1
  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/rescript-relay@3.0.1_@rescript+react@0.12.0_react-relay@17.0.0_relay-runtime@17.0.0_rescript@12.0.0-alpha.4/node_modules/rescript-relay/src/RescriptRelay.mjs
./src/App.mjs
   automatically enabled Fast Refresh for 2 custom loaders
 ⨯ ./node_modules/.pnpm/rescript-relay@3.0.1_@rescript+react@0.12.0_react-relay@17.0.0_relay-runtime@17.0.0_rescript@12.0.0-alpha.4/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/rescript-relay@3.0.1_@rescript+react@0.12.0_react-relay@17.0.0_relay-runtime@17.0.0_rescript@12.0.0-alpha.4/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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions