{"record":{"id":"914bf68577ffcb4f","repo":"apple/pkl","slug":"integeroverflow-914bf6","errorCode":"integerOverflow","errorMessage":"integerOverflow","messagePattern":"integerOverflow","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/expression/binary/MultiplicationNode.java","lineNumber":36,"sourceCode":"import com.oracle.truffle.api.CompilerDirectives;\nimport com.oracle.truffle.api.dsl.Specialization;\nimport com.oracle.truffle.api.nodes.NodeInfo;\nimport com.oracle.truffle.api.source.SourceSection;\nimport org.pkl.core.runtime.*;\n\n@NodeInfo(shortName = \"*\")\npublic abstract class MultiplicationNode extends BinaryExpressionNode {\n  protected MultiplicationNode(SourceSection sourceSection) {\n    super(sourceSection);\n  }\n\n  @Specialization\n  protected long eval(long left, long right) {\n    try {\n      return StrictMath.multiplyExact(left, right);\n    } catch (ArithmeticException e) {\n      CompilerDirectives.transferToInterpreter();\n      throw exceptionBuilder().evalError(\"integerOverflow\").build();\n    }\n  }\n\n  @Specialization\n  protected double eval(long left, double right) {\n    return left * right;\n  }\n\n  @Specialization\n  protected double eval(double left, long right) {\n    return left * right;\n  }\n\n  @Specialization\n  protected double eval(double left, double right) {\n    return left * right;\n  }\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/expression/binary/MultiplicationNode.java#L18-L54","documentation":"Pkl's `*` operator on two Ints uses StrictMath.multiplyExact and throws `integerOverflow` when the product exceeds the signed 64-bit Long range. Pkl never wraps integer multiplication silently. Reported at the multiplication expression in Pkl source.","triggerScenarios":"`left * right` where both are Int and the product is outside [-2^63, 2^63-1], e.g. `3037000500 * 3037000500`.","commonSituations":"Computing byte sizes, combinatorial counts, or squared values in size estimation code with large config numbers.","solutions":["Convert to Float/Double (`a.toDouble() * b`) when approximate results are fine","Reduce factor magnitudes or restructure the math","Perform the computation in a language/runtime with big integers and pass the result in as a String"],"exampleFix":"// before (Pkl)\nval bytes = 3037000500 * 3037000500\n// after\nval bytes = 3037000500.0 * 3037000500.0","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["arithmetic","integer-overflow","pkl"],"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"}