Skip to content

@inline integer constant outside the int32 range crashes the compiler #9299

Open

Description

@cknitt

An @inline integer constant outside the 32-bit range crashes the compiler instead of reporting an error.

@inline let big = 10000000000
let use = () => big
Fatal error: exception Failure("Int32.of_string")

The same happens in an interface:

@inline(10000000000)
let big: int

Without @inline, let plain = 10000000000 compiles with warning 107 ("Integer literal exceeds the range of representable integers of type int").

The built-in PPX converts the literal with Int32.of_string and doesn't catch the failure: compiler/frontend/bs_builtin_ppx.ml lines 495 and 620 on master (9523348). PR #8728 moves this code to Ast_external_mk.inline_const_of_expression without changing it.

Probably the simplest fix: report an error at the literal, or warning 107 and fall back to an ordinary binding.

Activity

  1. added theissue type on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions