[stdlib] Fix FileHandle.seek offset type from UInt64 to Int64#6387
Open
isaacuselman wants to merge 1 commit intomodular:mainfrom
Open
[stdlib] Fix FileHandle.seek offset type from UInt64 to Int64#6387isaacuselman wants to merge 1 commit intomodular:mainfrom
isaacuselman wants to merge 1 commit intomodular:mainfrom
Conversation
JoeLoser
reviewed
Apr 8, 2026
Member
JoeLoser
left a comment
There was a problem hiding this comment.
Do you mind adding some unit tests, please?
8e48cde to
96ca7b1
Compare
Contributor
Author
|
Added test_file_seek_int64_offset — tests positive, negative (SEEK_END), and relative negative (SEEK_CUR) Int64 offsets. |
96ca7b1 to
dce6f22
Compare
The `seek` method accepts `UInt64` for the offset parameter, but `lseek` takes a signed `off_t` and negative offsets are valid with SEEK_CUR and SEEK_END. The internal implementation already casts to Int64. This fixes the public API to match the actual semantics. Also fixes NamedTemporaryFile.seek which wraps FileHandle.seek. Fixes modular#4473 Assisted-by: Claude (Anthropic) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> :wq# You are currently rebasing branch 'fix-seek-int64' on '43e38e8'. :wq# ~ ~ ~ #
dce6f22 to
d4fbf7b
Compare
ConnorGray
approved these changes
Apr 15, 2026
Member
|
!sync |
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.
Fixes #4473
Summary
FileHandle.seekoffset parameter fromUInt64toInt64to matchlseeksemantics — negative offsets are valid withSEEK_CURandSEEK_ENDNamedTemporaryFile.seekwhich wrapsFileHandle.seektest_print.mojoto useInt64for the seek cursor (downstream consumer of the API change)test_file_seek_int64_offsetunit test covering positive, negative, and relative negative offsetsTesting
//mojo/stdlib/test/builtin:test_file.mojo.test— passes (includes new Int64 offset test)//mojo/stdlib/test/tempfile:test_tempfile.mojo.test— passes//mojo/stdlib/test/builtin:test_print.mojo.test— passes (updated cursor type)Checklist
./bazelw run formatto format my changesAssisted-by:trailer in my commit message or this PR description (see AI Tool Use Policy)