{"record":{"id":"6c43cfe94c9b24c4","repo":"apple/pkl","slug":"operatornotdefined2-6c43cf","errorCode":"operatorNotDefined2","errorMessage":"operatorNotDefined ${leftClass} (via operatorNotDefined helper)","messagePattern":"operatorNotDefined (.+?) \\(via operatorNotDefined helper\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/expression/binary/LogicalOrNode.java","lineNumber":36,"sourceCode":"import com.oracle.truffle.api.dsl.Specialization;\nimport com.oracle.truffle.api.frame.VirtualFrame;\nimport com.oracle.truffle.api.nodes.NodeInfo;\nimport com.oracle.truffle.api.nodes.UnexpectedResultException;\nimport com.oracle.truffle.api.source.SourceSection;\nimport org.pkl.core.ast.ExpressionNode;\n\n@NodeInfo(shortName = \"||\")\npublic abstract class LogicalOrNode extends ShortCircuitingExpressionNode {\n  protected LogicalOrNode(SourceSection sourceSection, ExpressionNode rightNode) {\n    super(sourceSection, rightNode);\n  }\n\n  @Specialization\n  protected boolean eval(VirtualFrame frame, boolean left) {\n    try {\n      return left || rightNode.executeBoolean(frame);\n    } catch (UnexpectedResultException e) {\n      throw operatorNotDefined(false, e.getResult());\n    }\n  }\n}\n","sourceCodeStart":18,"sourceCodeEnd":40,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/LogicalOrNode.java#L18-L40","documentation":"`||` short-circuit specialization requires the right operand to be Boolean; a non-Boolean result triggers operatorNotDefined, reported as operatorNotDefined2 for `||`. Same family as the LogicalAndNode failure, only for logical-or.","triggerScenarios":"`false || <nonBoolean>` e.g. `false || \"yes\"` or `flag || value` where `value` is an Int/String.","commonSituations":"Truthy-value assumptions ported from dynamic languages, or a fallback default that is a non-Boolean (e.g. `enabled || \"auto\"`).","solutions":["Convert the right side into a Boolean-valued expression","Fix the type of the property used on the right","Annotate the property as Boolean to catch it earlier"],"exampleFix":"// before (Pkl)\nval useTls = false || \"auto\"\n// after\nval useTls = false || (mode == \"tls\")","handlingStrategy":"type-guard","validationCode":"function isValidOrOperand(right) { return typeof right === 'boolean'; }","typeGuard":"const isBool = (v) => typeof v === 'boolean';","tryCatchPattern":null,"preventionTips":["Replace `x || default` with explicit comparisons or `??` for nullable defaults","Annotate referenced properties as Boolean","Validate lazy/defaulted properties actually produce Booleans"],"tags":["logical-operator","type-error","pkl"],"backgroundTag":"type-mismatch","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}