fs: std/fs path parameters take Into<Path> (step 2 of #68, PATH slice 2) #547
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Second step of #68 (PATH slice 2, the boundary). Step 1 (#419, commit
23bfecf) taught the compiler anativeparameter of typeInto<Path>: the call converts the argument once (path.into().show()), the runtime still receives onetorb_text, and a.Falliblenative builds itsIoErrorfrom that argument.std/fsstill declares every path parameter asString. This issue changes exactly those parameters and nothing else: callers that pass aString, a string literal or aPathall compile and behave as before.Source
docs/design/PATH.mdsection 6 ("std/fsanswersPathvalues", the signature listing), section 8 slice 2Goal
Every path parameter of the public
std/fssurface (File, and theFsoperations instd/fs/src/lib.trb) isInto<Path>instead ofString. Return types,IoError.pathandliststay as they are; they are steps 3 and 4 of #68.Acceptance criteria
std/fs/src/lib.trbevery parameter namedpath,to,target-as-path and theinsideof the temporary-entry functions that names a file or directory isInto<Path>(the native rowsopen,create,readText,writeText,exists,isDirectory,createDirectory,absolutePath,list,remove,rename,copy,createSymbolicLink,symbolicLinkTarget, the private nativesfileReadBytes,fileWriteBytes,fileReplace,fileMetadata,fileOwner,fileSetMode,fileCreateTemporary, and the non-native wrappersreadBytes,writeBytes,read,write,writeBytesAtomically,writeTextAtomically,walk,removeDirectory,move,metadata,linkMetadata,owner,linkOwner,setPermissions,createTemporaryFile,createTemporaryDirectory). IfInto<Path>?(theinside: ... ? = Noneparameters) is rejected by the checker, that one parameter staysString?and the diagnostic is quoted in the PR as the reason; every other parameter still changesabsolutePath,list,walk,symbolicLinkTargetand the temporary-entry functions still answerString/List<String>, andIoError.pathis still aString(it is built frompath.into().show()in the wrappers that construct it by hand)std/fsthat split or join the text (joinedPath,directoryOf,nameOf,walkInto,copiedEntry,removedEntry) keep working onStringand receive the/text of the path (.into().show()once at the entry of the wrapper); no behaviour of a result or an error message changesstd/fsneeds an edit; if the build shows one that does (an argument of a type that is neitherString, literal norPath), it is fixed in the same PR and listed in its bodystd/fs/tests/files.test.trbgains tests that fail onmain(compile error) and pass with the change: one operation each called with aStringvalue, a string literal and aPath(Path.from(...)), for a read (readText), a write (writeText), a two-path operation (renameorcopy) and a failure whoseIoError.pathis the/text of the path that was passedtests/conformance/programs that usestd/fsstill compare identical on the interpreter and the native build (no.expectedfile changes)docs/standard-library/fs.md(and the doc comments with code examples instd/fs/src/lib.trb, whichdocs checkcompiles) show theInto<Path>parameter types;docs/design/PATH.mdstatus header gets one sentence: the parameters ofstd/fsare in,list,IoError.pathandsystemPathare not; the header stays "partly implemented"skills/regenerated if the docs change requires itSeed
No change. This step uses the form that step 1 taught; it adds no native, no syntax and no name the compiler looks up. The compiler compiles itself with
std/fs, so the seed that bootstraps CI has to know the form: the newest published seed (142293fd98fc, head ofseeds.txt) contains23bfecf(checked withgit merge-base --is-ancestor 23bfecf 142293fd98fc), so CI bootstraps it without a seed run. The seed refresh of the main checkout'sseed/stays Torben's and is not needed for this PR.Out of scope
listansweringList<Path>,absolutePathansweringPath, the walkers that re-join names (step 4 of #68)IoError.pathbecoming aPath(step 3)systemPath(a new native, so its own step 2b of #68)std/io,std/process,compiler/,tools/callers beyond what compiles unchangedruntime/,seed/, releasesDependencies
Part of #68. Step 1 #419 is closed and on
main. Nothing else open.Commits
One
refactor(fs)commit for the signatures, onetest(fs)ordocs(fs)commit for tests and docs if the PR is easier to read that way; a single commit is fine too.Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68[loop:torbscript] claim implement by session:loop-torbscript-20261028 until 2026-10-28T21:22:25Z
[loop:torbscript] implement: PR #549 opened (3 commits: refactor/test/docs; all path parameters of std/fs are Into, local
torb test std/fs/tests/files.test.trb38 passed on the nightly toolchain; one deviation: private nativefileCreateTemporarykeeps aStringpath because the empty text means the system temp directory andPath.from("")is., reasoning in the PR), next: waiting (CI on PR and merge gate). Worker usage: one Sonnet 5.5 implement worker, token count not metered in the worker session.systemPathruntime native (step 2b of #68, commit 1 of 2) #559Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68IoError.pathbecomes aPath(step 3 of #68) #680