{"record":{"id":"4aca101e40806c62","repo":"karatelabs/karate","slug":"name-is-not-a-valid-parameter-name-in-strict-mode","errorCode":null,"errorMessage":"'${name}' is not a valid parameter name in strict mode","messagePattern":"'(.+?)' is not a valid parameter name in strict mode","errorType":"exception","errorClass":"ParserException","httpStatus":null,"severity":"error","filePath":"karate-js/src/main/java/io/karatelabs/parser/JsParser.java","lineNumber":1054,"sourceCode":"                nonSimple = true;\n                break;\n            }\n        }\n        if (!strict && !isArrow && !nonSimple) {\n            return;\n        }\n        List<String> names = new ArrayList<>();\n        for (int i = 0, n = args.size(); i < n; i++) {\n            Node arg = args.get(i);\n            if (arg.isToken() || arg.type != NodeType.FN_DECL_ARG) {\n                continue;\n            }\n            collectBindingBoundNames(arg, names);\n        }\n        if (strict) {\n            for (String name : names) {\n                if (isEvalOrArguments(name)) {\n                    throw new ParserException(\n                            \"'\" + name + \"' is not a valid parameter name in strict mode\");\n                }\n            }\n        }\n        if (strict || isArrow || nonSimple) {\n            String dup = firstDuplicate(names);\n            if (dup != null) {\n                throw new ParserException(\n                        \"duplicate parameter name '\" + dup + \"' is not allowed here\");\n            }\n        }\n    }\n\n    /** A FormalParameter is non-simple if it is a destructuring pattern, carries a\n     *  default initializer, or is a rest element — any of which makes the whole\n     *  parameter list non-simple, so duplicate bound names become an early error. */\n    private static boolean isNonSimpleParam(Node arg) {\n        for (int i = 0, n = arg.size(); i < n; i++) {","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-js/src/main/java/io/karatelabs/parser/JsParser.java#L1036-L1072","documentation":"In strict mode, `eval` and `arguments` are not valid parameter (binding) names. Karate collects all bound names of a function's parameter list — including destructured bindings — and rejects any occurrence when strict. This applies to plain and arrow functions alike.","triggerScenarios":"Declaring `function f(eval) {}`, `(arguments) => ...`, or destructured forms like `function f({eval: e}) {}` in strict-mode Karate JS.","commonSituations":"Callback signatures naively naming a parameter `arguments`; refactored code where a parameter was named after the built-in; code moved into strict scope (module/class).","solutions":["Rename the parameter (e.g. `args`, `argList`).","Update all uses of the parameter inside the function body to the new name.","If the intent was the implicit `arguments` object, use rest parameters instead: `function f(...args) {}`."],"exampleFix":"// before\n\"use strict\";\nconst log = (arguments) => console.log(arguments);\n// after\n\"use strict\";\nconst log = (...args) => console.log(args);","handlingStrategy":"validation","validationCode":"function assertNoReservedParams(fnSrc) {\n  const header = fnSrc.slice(0, fnSrc.indexOf(')') + 1);\n  const bad = header.match(/[\\s(,{[](eval|arguments)\\b/);\n  if (bad) throw new Error(\"parameter '\" + bad[1] + \"' is invalid in strict mode\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  karate.eval(script);\n} catch (e) {\n  if (String(e.message).includes('is not a valid parameter name in strict mode')) {\n    // rename the offending parameter and its uses, then re-evaluate\n  } else throw e;\n}","preventionTips":["Use `...args` rest parameters instead of naming a parameter `arguments`.","Keep a reserved-word list (eval, arguments) out of parameter names in code generators.","Run embedded scripts under Node --use-strict in CI to catch these early."],"tags":["javascript","strict-mode","reserved-word","parameters"],"backgroundTag":"invalid-identifier","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}