{"record":{"id":"827a5a0fabd31ba5","repo":"apple/pkl","slug":"operatornotdefined2-827a5a","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/LogicalAndNode.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 LogicalAndNode extends ShortCircuitingExpressionNode {\n  protected LogicalAndNode(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(true, 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/LogicalAndNode.java#L18-L40","documentation":"`&&` short-circuit specialization requires both sides to be Boolean; if the right operand evaluates to a non-Boolean (signalled via UnexpectedResultException), Pkl throws operatorNotDefined via the helper, reported as operatorNotDefined2 for `&&`. It indicates the right-hand side of a logical-and is not a Boolean.","triggerScenarios":"`true && <nonBoolean>` e.g. `true && 1` or `flag && someString` where the right side is a mistyped property or a lazy expression producing a non-Boolean.","commonSituations":"Config authors treating truthy integers/strings as conditions (habit from other languages) or a property referenced on the right side having an unintended type.","solutions":["Make the right operand a real Boolean expression (comparison, `.isEmpty`, etc.)","Fix the type of the referenced property on the right side","Add an explicit type annotation (`Boolean`) so it fails at type-check time"],"exampleFix":"// before (Pkl)\nval enabled = true && 1\n// after\nval enabled = true && (count > 0)","handlingStrategy":"type-guard","validationCode":"function isValidAndOperand(right) { return typeof right === 'boolean'; }","typeGuard":"const isBool = (v) => typeof v === 'boolean';","tryCatchPattern":null,"preventionTips":["Always produce Booleans from comparisons, never raw values","Annotate conditions as Boolean","Don't port truthy/falsy habits from JS/Python into Pkl"],"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"}