apple/pkl · error
operatorNotDefined2
operatorNotDefined2
Error message
operatorNotDefined ${leftClass} (via operatorNotDefined helper) What it means
`||` 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.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/ast/expression/binary/LogicalOrNode.java:36
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import org.pkl.core.ast.ExpressionNode;
@NodeInfo(shortName = "||")
public abstract class LogicalOrNode extends ShortCircuitingExpressionNode {
protected LogicalOrNode(SourceSection sourceSection, ExpressionNode rightNode) {
super(sourceSection, rightNode);
}
@Specialization
protected boolean eval(VirtualFrame frame, boolean left) {
try {
return left || rightNode.executeBoolean(frame);
} catch (UnexpectedResultException e) {
throw operatorNotDefined(false, e.getResult());
}
}
}
View on GitHub (pinned to f3efcbfc9b)
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
Example fix
// before (Pkl) val useTls = false || "auto" // after val useTls = false || (mode == "tls")
Defensive patterns
Strategy: type-guard
Validate before calling
function isValidOrOperand(right) { return typeof right === 'boolean'; } Type guard
const isBool = (v) => typeof v === 'boolean';
Prevention
- Replace `x || default` with explicit comparisons or `??` for nullable defaults
- Annotate referenced properties as Boolean
- Validate lazy/defaulted properties actually produce Booleans
When it happens
Trigger: `false || <nonBoolean>` e.g. `false || "yes"` or `flag || value` where `value` is an Int/String.
Common situations: Truthy-value assumptions ported from dynamic languages, or a fallback default that is a non-Boolean (e.g. `enabled || "auto"`).
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- operatorNotDefined2
- operatorNotDefinedLeft
- operatorNotDefined2
- operatorNotDefined1
- Node `%s` of type `%s` does not have a property named `%s`.
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/6c43cfe94c9b24c4.
Report an issue: GitHub.