Resize partial evaluation histories safely - #1241
Open
OskarEichler wants to merge 1 commit into
Open
Conversation
tompng
reviewed
Aug 30, 2026
| if size != 0 && size < @size | ||
| @contents = @contents[@size - size .. @size] | ||
| if size.positive? && @contents.size > size | ||
| @contents = @contents.last(size) |
Member
There was a problem hiding this comment.
Looks good 👍
Can you add a test for this?
Adding a test that does the below in test_eval_history.rb would be enough
out, err = execute_lines(
"IRB.CurrentContext.eval_history = 2",
"__",
conf: { EVAL_HISTORY: 5 }
)
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
Shrink evaluation history from the entries actually present rather than slicing with the configured maximum as an array index.
Reproduction
When a history configured for 100 entries currently contains only three, resizing it to two slices from index 98 and replaces the contents with
nil. The candidate retains the last two entries and does nothing when the populated history is already within the new limit.Verification
Compatibility
Unlimited and non-shrinking sizes remain unchanged; partial histories now follow the configured limit safely. Prepared with AI-assisted source review; no repository tests were changed.