Repository navigation
Migrator contracts, step 2 (D159, #2615): a proved function is printed as a method of its record - #2623
Merged
Conversation
added 6 commits
October 25, 2026 00:33
…d as a method of its record A function whose first parameter is a mutated corpus record (receiver-mut) and whose other pointer parameters are proved out-parameters is emitted as `pub mut fn <m>` in an `impl R:` block at the end of its unit: the out-parameter is the return (`T`, or `(status, T)`), a return of the receiver itself is `-> &R from self`, and the body is printed in a safe context with its raw operations carrying their own unsafe. Corpus calls to one print as method calls, an out-argument assigned from the return. A function with an unproved pointer keeps its raw signature under a `// contract:` line. The view verdict now refuses a NULL return path and is drawn beside receiver-mut. The basic test covers each shape and type-checks the output.
A static definition (a unit's own or a header's inline one) keeps its raw signature in the printer, so it takes no method shape either (the calls were being rewritten to methods that were never printed). Pointer arithmetic carries its pointer type, so a field read through it prints with the unsafe a safe method body needs (M*LIB). A typedef that renames a record is an alias, not a record an impl can attach to. A handle the body accepts as NULL, or a corpus caller passes NULL, is no receiver: pcre2's `pcre2_set_optimize(NULL, …)` returns an error, a method's self is never NULL.
…n the check tree, where their imports find them They were copied under lib/std/re, so `use std.engines.pcre2.X` found no sibling there and fell back to the checkout's promoted corpus: the fresh harness was checked against the old library and a signature change in the fresh one could not be seen (D159 step 2's methods were "unknown" for that reason). The generic corpus_check_every_module already uses the import path's layout.
…hod too The unit that publishes a header's static inline definition prints it `pub`, so the shape applies to it as to any published function; only a unit's own static, and a header no single unit owns (a private copy per includer), keep the raw signature. STC's word shapes (stack.h instantiated in facade_shapes.c) are the case: push, pop and reserve are now methods of stc_word_stack.
…the ruling; no explicit Unit on the setters behav_migrate_anon_union_field and behav_migrate_no_redundant_unsafe migrated a `bump(struct S *)` and called it as a free unsafe function; under D159 it is a method of the record, called safely as `s.bump(…)`, and the raw-function assertions hold for the functions that stay raw. The two new setters drop their written `-> Unit` (unit-return-review).
Contributor
Author
|
Battery green on a02f7e3, seed-driven under nightly-20261025-local-1-c88f3eeff0bc (tools/battery.w: gate, uat, battery-checks). corpus-migrator-gate green on the fresh migrations of every corpus (pcre2test passes upstream RunTest). |
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.
D159 step 2 (#2615): the migrator prints a proved function as a method of its record.
pub mut fn <m>in animpl R:block at the end of its unit; the out-parameter is the return (T, or(status, T)), a returned receiver is-> &R from self; the body prints in a safe context with its raw operations carrying their ownunsafe. Corpus calls print as method calls, an out-argument assigned from the return. A function with an unproved pointer keeps its raw signature under a// contract:line.ret-fromon a path that returns NULL is unproved; a unit-local static, a header no single unit owns, a variadic, a method-name collision keep the raw form; a header-owned inline definition (STC templates) is a method. Pointer arithmetic now carries its pointer type.Battery: seed-driven, posted below when green.