{"record":{"id":"300f77898872d26e","repo":"karatelabs/karate","slug":"name-is-not-a-valid-binding-name-in-strict-mode","errorCode":null,"errorMessage":"'${name}' is not a valid binding name in strict mode","messagePattern":"'(.+?)' is not a valid binding name in strict mode","errorType":"exception","errorClass":"ParserException","httpStatus":null,"severity":"error","filePath":"karate-js/src/main/java/io/karatelabs/parser/JsParser.java","lineNumber":1133,"sourceCode":"            } else {\n                binding = ch; // LIT_ARRAY / LIT_OBJECT pattern\n                break;\n            }\n        }\n        if (binding == null) {\n            return;\n        }\n        List<String> names = new ArrayList<>();\n        collectBoundNames(binding, names);\n        String dup = firstDuplicate(names);\n        if (dup != null) {\n            throw new ParserException(\n                    \"duplicate binding name '\" + dup + \"' is not allowed in a catch parameter\");\n        }\n        if (strict) {\n            for (String name : names) {\n                if (isEvalOrArguments(name)) {\n                    throw new ParserException(\n                            \"'\" + name + \"' is not a valid binding name in strict mode\");\n                }\n            }\n        }\n    }\n\n    /** A strict var/let/const declaration may not bind {@code eval} / {@code arguments}\n     *  — including inside a destructuring pattern. (Lexical duplicate-BoundNames for\n     *  let/const patterns is a distinct rule, deferred — VAR_DECL doesn't carry the\n     *  let-vs-var distinction.) */\n    private static void checkVarDeclName(Node varDecl) {\n        List<String> names = new ArrayList<>();\n        collectBindingBoundNames(varDecl, names);\n        for (String name : names) {\n            if (isEvalOrArguments(name)) {\n                throw new ParserException(\n                        \"'\" + name + \"' is not a valid binding name in strict mode\");\n            }","sourceCodeStart":1115,"sourceCodeEnd":1151,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-js/src/main/java/io/karatelabs/parser/JsParser.java#L1115-L1151","documentation":"In strict mode, `eval` and `arguments` may not be used as catch-parameter binding names. Karate validates every name bound by the catch parameter (including destructured bindings) and throws when the script is strict.","triggerScenarios":"Writing `try {} catch (eval) {}`, `catch (arguments) {}`, or destructured forms like `catch ({eval: e}) {}` in strict-mode Karate JS.","commonSituations":"Naming the caught error `eval` by accident or as shorthand; porting old code where the catch var was called `arguments`; strict contexts (class bodies, modules) activating checks that sloppy mode skipped.","solutions":["Rename the catch parameter (e.g. `err`, `ex`).","Update references to the parameter inside the catch block.","If destructuring, keep the property name but change the binding: `catch ({eval: evalValue})` — the property key `eval` is fine, the binding name is not."],"exampleFix":"// before\ntry { run(); } catch (eval) { log(eval.message); }\n// after\ntry { run(); } catch (err) { log(err.message); }","handlingStrategy":"validation","validationCode":"function assertValidCatchBinding(catchSrc) {\n  const m = catchSrc.match(/catch\\s*\\(\\s*([\\w$]+)/);\n  if (m && /^(eval|arguments)$/.test(m[1])) {\n    throw new Error(\"catch binding '\" + m[1] + \"' is invalid in strict mode\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  karate.eval(script);\n} catch (e) {\n  if (String(e.message).includes(\"is not a valid binding name in strict mode\")) {\n    // rename the catch parameter (e.g. to 'err') and its uses\n  } else throw e;\n}","preventionTips":["Use a standard catch parameter name like `err`/`e` consistently.","Do not name bindings after built-ins (`eval`, `arguments`).","Destructure in the catch body, aliasing reserved keys: `catch (e) { const { eval: evalKey } = e; }`."],"tags":["javascript","strict-mode","reserved-word","catch-clause"],"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"}