Repository navigation
OFFSET: huge offsets and sizes give #REF! instead of overflowing - #466
Merged
h-a-n-a-s-h-i merged 1 commit intoOct 13, 2026
Merged
Conversation
Member
|
Merged — thank you @webdevtodayjason for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
=OFFSET(B2,1E300,0)and=OFFSET(B2,0,0,1E300,1)failedcell.setwithInternal("cell.set", "attempt to add with overflow"). The row, column, height and width arguments are truncated to i64, which saturates for huge values, and the plain additions that place the result then overflow. Excel returns#REF!for these.The additions now saturate, so any argument that would land outside the sheet returns
#REF!like other out-of-range offsets. Normal offsets, negative heights and widths, fractional truncation and results at the last row or column are unchanged.How it was tested
offset_extreme_arguments_return_ref(calc) andcrates/engine/tests/offset_overflow.rs(cell.set) cover huge positive and negative rows, columns, heights and widths, combinations of them, and a full-height result at the sheet edge. They fail on current main with the overflow and pass with this change.cargo test -p gridcraft-calcpasses.cargo fmt --checkandcargo clippy --workspace --all-targets -- -D warningspass.cargo xtaskassets, layers, wasm andparity --checkpass.cargo test --workspacehas three failures that also happen on current main without this change (same as the main CI run):csv_save_keeps_the_separator_it_was_opened_withandsaving_an_opened_semicolon_csv_keeps_semicolons(1.24412E+11instead of124412140710), andtranslations_are_unique_and_preserve_unknown_text(missing French for "Different First Page"). CSV/text export: General numbers without exponents (integers below 1e16 exact);&switches to scientific past 21 characters #449 addresses these.