Skip to content

Suggestion: Do not fail the whole irep load on an unsupported integer literal - #308

Merged
HirohitoHigashi merged 1 commit into
mrubyc:masterfrom
hasumikin:fix/defer-unsupported-int-literal-error
Aug 20, 2026
Merged

HirohitoHigashi merged 1 commit into
mrubyc:masterfrom
hasumikin:fix/defer-unsupported-int-literal-error

Conversation

@hasumikin

Copy link
Copy Markdown
Member

Background

load_irep_1() raised and returned NULL as soon as it saw an IREP_TT_INT64 or IREP_TT_BIGINT pool entry in a build without MRBC_INT64.
That error propagates through load_irep() and mrbc_load_irep() up to mrbc_load_mrb(), so one literal the program may never evaluate aborts the load of the entire bytecode chunk and takes every class and method defined in it down with it.

Suggestion

Skip the entry instead.
Its size is known and does not depend on the integer width: 8 bytes for INT64, and for BIGINT the length byte plus the base byte plus that many digits, which is what conv_bigint() reads.
The error moves to mrbc_irep_pool_value(), which runs only when the VM actually fetches the literal.

A build that cannot represent the value still cannot use it. Only the code that touches it fails now, instead of everything around it.

load_irep_1() raised and returned NULL as soon as it saw an
IREP_TT_INT64 or IREP_TT_BIGINT pool entry in a build without
MRBC_INT64. That error propagates through load_irep() and
mrbc_load_irep() up to mrbc_load_mrb(), so one literal the program may
never evaluate aborts the load of the entire bytecode chunk and takes
every class and method defined in it down with it.

Skip the entry instead. Its size is known and does not depend on the
integer width: 8 bytes for INT64, and for BIGINT the length byte plus
the base byte plus that many digits, which is what conv_bigint() reads.
The error moves to mrbc_irep_pool_value(), which runs only when the VM
actually fetches the literal.

A build that cannot represent the value still cannot use it. Only the
code that touches it fails now, instead of everything around it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@HirohitoHigashi
HirohitoHigashi merged commit dc7daae into mrubyc:master Aug 20, 2026
8 checks passed
@hasumikin
hasumikin deleted the fix/defer-unsupported-int-literal-error branch August 21, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants