{"record":{"id":"1e45f171196a57b1","repo":"apple/pkl","slug":"type-mismatch-nothing-type","errorCode":null,"errorMessage":"type mismatch (Nothing type)","messagePattern":"type mismatch \\(Nothing type\\)","errorType":"error_code","errorClass":"VmTypeMismatchException.Nothing","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java","lineNumber":393,"sourceCode":"    }\n  }\n\n  /** The `nothing` type. */\n  public static final class NothingTypeNode extends TypeNode {\n    public NothingTypeNode(SourceSection sourceSection) {\n      super(sourceSection);\n    }\n\n    @Override\n    public TypeNode initWriteSlotNode(int slot) {\n      // do nothing\n      return this;\n    }\n\n    @Override\n    protected Object executeLazily(VirtualFrame frame, Object value) {\n      CompilerDirectives.transferToInterpreter();\n      throw new VmTypeMismatchException.Nothing(sourceSection, value);\n    }\n\n    @Override\n    public Object executeAndSet(VirtualFrame frame, Object value) {\n      executeLazily(frame, value);\n      // guaranteed to never run (execute will always throw).\n      CompilerDirectives.transferToInterpreter();\n      throw PklBugException.unreachableCode();\n    }\n\n    @Override\n    public FrameSlotKind getFrameSlotKind() {\n      return FrameSlotKind.Illegal;\n    }\n\n    @Override\n    public VmTyped getMirror() {\n      return MirrorFactories.nothingTypeFactory.create(null);","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java#L375-L411","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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`."],"exampleFix":"// before (Pkl)\nclass Impl extends Template {\n  reserved: nothing = \"oops\"\n}\n// after\nclass Impl extends Template {\n  // do not define `reserved`; it is typed `nothing`\n}","handlingStrategy":"validation","validationCode":"// Pkl: ensure nothing-typed properties stay unset\nif (hasProperty(reserved)) {\n  error(\"`reserved` is typed nothing and must not be defined\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["nothing-type","type-mismatch","bottom-type","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"}