{"record":{"id":"8ff3367899ccff9a","repo":"apple/pkl","slug":"vmtypemismatchexception-simple-value-is-not-an-in","errorCode":null,"errorMessage":"VmTypeMismatchException.Simple (value is not an Int)","messagePattern":"VmTypeMismatchException\\.Simple \\(value is not an Int\\)","errorType":"exception","errorClass":"VmTypeMismatchException.Simple","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java","lineNumber":2546,"sourceCode":"\n    IntMaskSlotTypeNode(long mask) {\n      super(VmUtils.unavailableSourceSection());\n      this.mask = mask;\n    }\n\n    @Override\n    protected final Object executeLazily(VirtualFrame frame, Object value) {\n      var typealias = getVmTypeAlias();\n      assert typealias != null;\n      if (value instanceof Long l) {\n        if ((l & mask) == l) return value;\n\n        CompilerDirectives.transferToInterpreterAndInvalidate();\n        var sourceSection = typealias.getConstraintSection();\n        throw constraintException(value, sourceSection);\n      }\n\n      throw new VmTypeMismatchException.Simple(\n          typealias.getBaseTypeSection(), value, BaseModule.getIntClass());\n    }\n\n    @Override\n    public final VmClass getVmClass() {\n      return BaseModule.getIntClass();\n    }\n\n    @Override\n    public final VmTyped getMirror() {\n      return MirrorFactories.typeAliasTypeFactory.create(this);\n    }\n\n    @Override\n    public final boolean doIsEquivalentTo(TypeNode other) {\n      return other instanceof IntMaskSlotTypeNode typeNode && mask == typeNode.mask;\n    }\n","sourceCodeStart":2528,"sourceCodeEnd":2564,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java#L2528-L2564","documentation":"IntTypeAliasTypeNode checks that a value assigned to the `Int` typealias is actually an Int. If the value is not an integer at all (and any constraint check earlier already handled constrained failures), it throws VmTypeMismatchException.Simple with BaseModule.getIntClass(), i.e. 'expected Int, got <other type>'.","triggerScenarios":"A property or expression typed `Int` receives a Float, String, Boolean, or other non-Int value; e.g. `port: Int = \"8080\"` or `port: Int = 8080.0`.","commonSituations":"Numbers parsed from JSON/YAML/CLI input arrive as strings or floats; Pkl `Number` literals with decimal points; unquoted config values that render as strings.","solutions":["Convert the value to an Int in Pkl: use `.toInt()` for strings/floats, or write the literal without a decimal point.","Change the annotation to `Number` (or `Int|Float`) if the value may legitimately be fractional.","Fix the upstream producer to emit an integer."],"exampleFix":"// before\nport: Int = \"8080\"\n// after\nport: Int = \"8080\".toInt()","handlingStrategy":"validation","validationCode":"// Pkl: coerce before assigning to Int\nport: Int = (externalValue as String).toInt()","typeGuard":"value is Int","tryCatchPattern":null,"preventionTips":["Convert string/float inputs with .toInt() at the module boundary.","Use `Number` only when fractional values are legitimate.","Quote config values deliberately; unquoted values may parse as strings."],"tags":["pkl","type-mismatch","int"],"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"}