apple/pkl · error · VmTypeMismatchException.Nothing
type mismatch (Nothing type)
Error message
type mismatch (Nothing type)
What it means
When a value must conform to the `nothing` type, it can never be valid: TypeNode's Nothing implementation's executeLazily unconditionally throws VmTypeMismatchException.Nothing, reported as "type mismatch (Nothing type)". `nothing` is Pkl's bottom type used to mark values/properties that must never be set or that are intentionally absent.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java:393
}
}
/** The `nothing` type. */
public static final class NothingTypeNode extends TypeNode {
public NothingTypeNode(SourceSection sourceSection) {
super(sourceSection);
}
@Override
public TypeNode initWriteSlotNode(int slot) {
// do nothing
return this;
}
@Override
protected Object executeLazily(VirtualFrame frame, Object value) {
CompilerDirectives.transferToInterpreter();
throw new VmTypeMismatchException.Nothing(sourceSection, value);
}
@Override
public Object executeAndSet(VirtualFrame frame, Object value) {
executeLazily(frame, value);
// guaranteed to never run (execute will always throw).
CompilerDirectives.transferToInterpreter();
throw PklBugException.unreachableCode();
}
@Override
public FrameSlotKind getFrameSlotKind() {
return FrameSlotKind.Illegal;
}
@Override
public VmTyped getMirror() {
return MirrorFactories.nothingTypeFactory.create(null);View on GitHub (pinned to f3efcbfc9b)
Solutions
- Remove the value assignment: a property typed `nothing` must not be given any value in this module/context.
- If the property should hold a value, change its declared type from `nothing` to the actual expected type.
- Check the template/abstract module documentation for whether the property is expected to remain unassigned or be overridden in a specific way.
- If you intended a nullable placeholder, use `Null`-able types (e.g. `String?`) instead of `nothing`.
Example fix
// before (Pkl)
class Impl extends Template {
reserved: nothing = "oops"
}
// after
class Impl extends Template {
// do not define `reserved`; it is typed `nothing`
} Defensive patterns
Strategy: validation
Validate before calling
// Pkl: ensure nothing-typed properties stay unset
if (hasProperty(reserved)) {
error("`reserved` is typed nothing and must not be defined")
} Prevention
- Treat `nothing`-typed properties in templates as 'do not define'.
- Use nullable types (T?) instead of nothing for optional placeholders.
- Read abstract/template module contracts before overriding properties.
When it happens
Trigger: Assigning or evaluating any value where the expected type is `nothing` — e.g. filling in a property declared `nothing` in an abstract module, or a template expecting an overriding module to leave the property unset (declared `nothing`) but a concrete value was provided.
Common situations: Extending template/abstract modules where a `x: nothing` property means "must not be defined here" but the subclass defines it; misusing `nothing` as if it were a nullable placeholder type.
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
- Error converting property `%s` in Pkl object of type `%s` to
- The top-level value of a YAML stream must have type `Collect
- type constraint mismatch
- type mismatch
- union type mismatch
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/1e45f171196a57b1.
Report an issue: GitHub.