{"record":{"id":"3e15c83435a255ff","repo":"apple/pkl","slug":"inttoolarge","errorCode":"intTooLarge","errorMessage":"intTooLarge","messagePattern":"intTooLarge","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":711,"sourceCode":"\n    // relies on grammar rule nesting depth, but a breakage won't go unnoticed by tests\n    if (expr.parent() instanceof UnaryMinusExpr) {\n      // handle negation here to make parsing of base.MinInt work\n      // also moves negation from runtime to parse time\n      text = \"-\" + text;\n    }\n    return parser.apply(text, radix);\n  }\n\n  @Override\n  public IntLiteralNode visitIntLiteralExpr(IntLiteralExpr expr) {\n    var section = createSourceSection(expr);\n    try {\n      var num = parseInt(expr, Long::parseLong);\n      return new IntLiteralNode(section, num);\n    } catch (NumberFormatException e) {\n      var text = expr.getNumber();\n      throw exceptionBuilder().evalError(\"intTooLarge\", text).withSourceSection(section).build();\n    }\n  }\n\n  @Override\n  public FloatLiteralNode visitFloatLiteralExpr(FloatLiteralExpr expr) {\n    var section = createSourceSection(expr);\n    var text = VmUtils.removeUnderscoresFromNumber(expr.getNumber(), true);\n    // relies on grammar rule nesting depth, but a breakage won't go unnoticed by tests\n    if (expr.parent() instanceof UnaryMinusExpr) {\n      // handle negation here for consistency with visitIntegerLiteral\n      // also moves negation from runtime to parse time\n      text = \"-\" + text;\n    }\n\n    try {\n      var num = Double.parseDouble(text);\n      return new FloatLiteralNode(section, num);\n    } catch (NumberFormatException e) {","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L693-L729","documentation":"Pkl integer literals must fit in a signed 64-bit (Long) value. When `parseInt` fails via `Long::parseLong` throwing NumberFormatException, the builder reports that the integer is too large rather than silently truncating or promoting to Float.","triggerScenarios":"Writing an Int literal whose magnitude exceeds Long.MIN_VALUE..Long.MAX_VALUE (about 9.2 * 10^18), e.g. `x = 99999999999999999999`.","commonSituations":"Pasting large constants (IDs, hashes, seconds-since-epoch in nanoseconds) from other languages that use arbitrary-precision or unsigned 64-bit integers.","solutions":["Reduce the literal to within the signed 64-bit range.","Write the value as a Float literal (append `.0`) if approximate precision suffices.","Encode the value as a String and parse it in code outside Pkl, or split into components."],"exampleFix":"// before\nx = 12345678901234567890123\n// after\nx: Float = 1.2345678901234568e22","handlingStrategy":"validation","validationCode":"// Guard before emitting a Pkl Int literal (JS example):\nfunction withinInt64(n) {\n  return Number.isInteger(n) && n >= -(2n**63n) && n <= 2n**63n - 1n;\n}","typeGuard":"const isPklInt = (v: bigint | number): boolean =>\n  typeof v === 'bigint'\n    ? v >= -(2n ** 63n) && v <= 2n ** 63n - 1n\n    : Number.isSafeInteger(v);","tryCatchPattern":"try {\n  renderPklConfig(cfg);\n} catch (e) {\n  if (String(e).includes('intTooLarge')) {\n    // downgrade to Float or String representation\n  }\n}","preventionTips":["Check constants against ±9223372036854775807 before embedding them in Pkl.","Use Float or String properties for large identifiers or nanosecond timestamps."],"tags":["pkl","integer","overflow"],"backgroundTag":"value-out-of-range","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"}