natives: Into<Path> parameters and a Path in IoError.path (teach the compiler, commit 1 of 2 for #68) #419
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
First step of #68 (PATH slice 2, the boundary). Slice 1 (
std/path) and the checker condition of PATH.md section 5 are in: a receiver of the trait typeInto<Path>resolvesinto()as an ordinary trait call (compiler/tests/conversions.test.trb), andstd/fsalready passes the/text form to the runtime on every system.What is not proved is the native side: every
std/fsnative still hasStringparameters, and the lowering builds theIoErrorof a.Falliblenative from the native's parameter namedpath(compiler/src/backend/c/natives.trb, the.Fallibleconvention). Before anystd/fssignature can change, both back ends and the lowering must accept a native parameter of typeInto<Path>and anIoErrorwhosepathis aPath. This issue teaches that and nothing else (commit 1 of 2 of the seed rule); the migration ofstd/fsis the following step of #68.Source
docs/design/PATH.mdsection 5 (Into<Path>as a parameter type), section 6 (the boundary to the operating system, thestd/fslisting) and section 8, slice 2Goal
A
native fnornative static fnmay declare a parameterpath: Into<Path>; the C back end passes the runtime the/text of that path (path.into().show(), converted once at the call), and theIoErrora.Falliblenative answers can carrypath: Pathas well aspath: String, chosen by the declared field type.Acceptance criteria
Into<Path>; the runtime function it maps to still receives onetorb_text(no change inruntime/)String, a string literal and aPathargument works (the literal rule and the blanketIntogive the first two,PathisInto<Path>throughFrom<Path>).Falliblenative with anInto<Path>parameter builds itsIoErrorwith thePathof that argument whenIoError.pathis declaredPath, and keeps building it from theStringparameter when it is declaredString(both forms stay valid until step 3 of #68)tests/conformance/that compares the interpreter and the native build over the three argument kinds and an error message that names the path (use a fixture native or an existing one that is not astd/fssignature, sostd/fsstays untouched)docs/design/PATH.mdslice 2 gets a line saying which half is in (the native side); the status header stays "partly implemented"Seed
Yes: changes how the lowering and the C back end read a native signature, and the compiler compiles itself with it. Two-commit rule of
CLAUDE.md"Seed and breaking changes": this issue is commit 1 (teach, nostdor compiler source uses the new form yet). The seed refresh stays Torben's; migratingstd/fswaits for it.Scope
compiler/src/semantics/checker/*only where a native signature rejects a trait-typed parametercompiler/src/ir/lower/*,compiler/src/backend/c/natives.trbcompiler/tests/andtests/conformance/, the one PATH.md lineOut of scope
std/fs,std/io,std/processsignature (steps 2 and 3 of #68),listansweringList<Path>runtime/(the Windows half is already in),seed/, releasesDependencies
None open: slice 1 and the checker condition are on
main. Part of #68.Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T13:33:00Z
Into<Path>signatures (PATH slice 2) #68systemPathruntime native (step 2b of #68, commit 1 of 2) #559Into<Path>signatures (PATH slice 2) #68Into<Path>signatures (PATH slice 2) #68IoError.pathbecomes aPath(step 3 of #68) #680