{"record":{"id":"dbd69b8f56687bca","repo":"karatelabs/karate","slug":"cannot-apply-pre-inc-dec-to-node","errorCode":null,"errorMessage":"cannot apply pre inc/dec to: ${node}","messagePattern":"cannot apply pre inc/dec to: (.+?)","errorType":"exception","errorClass":"JsErrorException (typeError)","httpStatus":null,"severity":"error","filePath":"karate-js/src/main/java/io/karatelabs/js/PropertyAccess.java","lineNumber":596,"sourceCode":"                        throw SlotTable.tdzError(node.getText());\n                    }\n                    Object step = Terms.incDecStep(oldValue);\n                    Object newValue = isIncrement ? Terms.add(oldValue, step, context) : Terms.min(oldValue, step, context);\n                    context.updateSlot(slot, newValue, null);\n                    yield newValue;\n                }\n                yield incDecRefByName(node, context, isIncrement, true);\n            }\n            case REF_DOT_EXPR, REF_BRACKET_EXPR -> {\n                AccessSite site = resolveWriteSite(node, context);\n                if (site == null || site == SHORT_CIRCUIT_SITE) yield Terms.UNDEFINED;\n                if (site.privateName != null) yield privateIncDec(site, isIncrement, true, context);\n                if (site.receiver != null) yield superIncDec(site, isIncrement, true, context);\n                yield site.isIndex\n                        ? preIncDecByIndex(site.target, site.key, isIncrement, context)\n                        : preIncDecByName(site.target, (String) site.key, isIncrement, context);\n            }\n            default -> throw JsErrorException.typeError(\"cannot apply pre inc/dec to: \" + node);\n        };\n    }\n\n    /**\n     * Delete a property. Returns true on success.\n     */\n    static boolean delete(Node node, CoreContext context) {\n                return switch (node.type) {\n            case REF_EXPR -> false; // Can't delete variables\n            case REF_DOT_EXPR, REF_BRACKET_EXPR -> {\n                AccessSite site;\n                try {\n                    site = resolveWriteSite(node, context);\n                } catch (JsErrorException e) {\n                    // delete on `?.()` shape: legacy behavior was to return false silently\n                    yield false;\n                }\n                // a short-circuited chain leaves no reference to delete, which","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-js/src/main/java/io/karatelabs/js/PropertyAccess.java#L578-L614","documentation":"A TypeError thrown when a pre-increment/decrement operator is applied to a node type the evaluator does not support as an update target. Valid targets are variable references, property accesses (with private/super/index/name handling), and literals are simply not reachable here; anything else hits the default arm.","triggerScenarios":"Executing `++expr`/`--expr` where expr parses as an unsupported node shape — e.g. `++(a, b)`, `++foo()`, or a malformed AST node from a parser defect.","commonSituations":"Hand-written invalid JS like `++obj.getMethod()`; code generators or transpilers emitting bad increment targets; parser/interpreter version skew.","solutions":["Rewrite the target as a variable or property: `++obj.count`","Store the expression in a variable, then apply `++` to that variable","If the source is valid, check for a parser regression and upgrade"],"exampleFix":"// before\n++(x + y);\n// after\nlet s = x + y;\n++s;","handlingStrategy":"validation","validationCode":"// Reject pre-inc/dec on non-assignable expressions before eval\nif (/\\+\\+\\s*[(\\d'\"]|--\\s*[(\\d'\"]/.test(code)) { /* invalid pre-inc/dec target */ }","typeGuard":"function isPreIncDecTarget(node) {\n  return node && ['Identifier','MemberExpression'].includes(node.type);\n}","tryCatchPattern":null,"preventionTips":["Apply ++/-- only to variables or properties","Rewrite `++call()` patterns into explicit assign-then-increment","Validate generated ASTs before interpretation"],"tags":["javascript","ast","unsupported-lhs"],"backgroundTag":"unsupported-operation","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}