Repository navigation
fix(fc): return Erange when last_hist < 0 instead of wrapping to usize::MAX - #4233
Merged
caomengxuan666 merged 1 commit intoNov 27, 2026
Merged
Conversation
Member
|
CAPTAIN-VERIFY(运行时复验,devin-mac 实跑):新钉绿、fail-first 成立(摘 Erange 守卫即复现 capacity overflow panic);oracle 侧 fc 索引模型观察项已由队长另行记录、非本 PR 返工项。 证据达合入门,队长合入。 |
This was referenced Nov 27, 2026
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.
Summary
if last_hist < 0 { return Err(SpecErr::Erange); }at the top offc_gethnuminsrc/builtins/fc.rs, matching GNU Bash 5.3builtins/fc.def:599-600(fc_gethnum:if (last_hist < 0) return (-1);).fc_gethnumnumeric parsing and offset arithmetic toi128(and check digits inis_number_argwithoutisizeparse failure) so oversized numeric specs clamp cleanly instead of wrapping or misparsing as flags.fc -l 0orfc -l 1 2as the first interactive command (count == 1,last_hist == -1) cast-1i64 as usize(usize::MAX) and panicked withcapacity overflowwhen collecting(histbeg..=histend).What was removed
last_hist as usizecasts whenlast_hist < 0ands.parse::<i64>().unwrap_or(0)fallback infc_gethnum.Verification
python3 scripts/check-rustfmt.py: okbash scripts/check-utf8-boundary-hygiene.sh: cleanpython3 scripts/check-marker-literals.py: OKcargo test --lib builtins::fc::tests::test_fc_negative_last_hist_on_sole_current_entry_returns_erange: 1 passed, 0 failed (macOS aarch64; fail-first panicked withcapacity overflowon master)