Repository navigation
migrate: a migrated module's types are pub — the §18.1 check rejected every pub fn naming c_int or a header struct - #1309
Merged
Conversation
… every pub fn naming c_int or a header struct The §18.1 check (#1284, SemaDecl.check_pub_signature_names_public_types) is correct: it resolves the named type in the same module and reads its pub flag. The migrator's single-file output was genuinely inconsistent: `--no-c-export` makes every non-static function `pub`, while the preamble emitted `type c_int = i32` (and every struct/typedef/enum rendering site in CImport.w emits `type X ...`) privately. So `pub fn verify() -> c_int` named a private alias, and every behav_migrate_*.w test went red on main. The multi-file corpus path never had the problem: it routes every type to defs.w and ci_migrate_publicize_shared_defs prefixes `pub` on each declaration there, which is why lib/std/{re,zl,c_algorithms,tommyds}/defs.w already carry `pub type c_int = i32`. The single-file path now applies the same rule to its type lines (ci_migrate_publicize_types): C has no type visibility, a migrated module's types are its public API, and static functions stay private as before. Corpus modules carry no `type` lines outside defs.w, so the pass is a no-op on them and no re-migration is needed. Verified under the fresh stage2: 26/26 test/behavior/behav_migrate_*.w pass; err_pub_fn_names_private_type, err_pub_method_on_private_type and pub_fn_generic_param_not_private still pass.
Contributor
Author
|
Battery: build rc=0, :fixpoint rc=0, :test rc=1 — all 26 |
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.
Root cause
Main's battery is red: every
test/behavior/behav_migrate_*.w(26 tests) fails withThe §18.1 check (#1284,
SemaDecl.check_pub_signature_names_public_types) is correct and unchanged: it resolves the named type in the same module and reads itspubflag.c_intthere is genuinely private — the migrator's single-file output was inconsistent with itself:--no-c-exportmakes every non-static functionpub(CiMigrate.w,visibility),type c_int = i32(and the ~20 struct/typedef/enum rendering sites inCImport.wemittype X ...) with nopub.So
pub fn verify() -> c_intnamed a private alias;Pair make_pair(void)(behav_migrate_named_record_tags) named a private struct the same way.c_intis not a prelude/std.libc type (neither defines it); it is only the migrator's own alias, so there was nothing for the check to misclassify.The multi-file corpus path never had the problem: it routes every type to
defs.w, andci_migrate_publicize_shared_defsprefixespubon each declaration there — which is whylib/std/{re,zl,c_algorithms,tommyds}/defs.walready carrypub type c_int = i32and the corpora compile under the new check.Fix
The single-file path now applies the same rule to its
typelines (ci_migrate_publicize_types, sharing one line walker with the defs.w publicizer): C has no type visibility, a migrated module's types are its public API, and static functions stay private as before (verified:static int hiddenstill migrates to a privatefn hidden).No corpus re-migration is needed: no corpus module carries a
typeline outsidedefs.w(rg -c '^type ' lib/std/{re,zl,c_algorithms,tommyds}/*.wis 0 everywhere), so the pass is a no-op on their output and the promoted trees are byte-identical to what a re-migrate would write.Verification (fresh stage2 from this branch;
:devstage1 cannot run these tests — it embeds no bundles, sostd.reis unresolvable from the p7 case dir)test/behavior/behav_migrate_*.wpasserr_pub_fn_names_private_type,err_pub_method_on_private_type,pub_fn_generic_param_not_privatestill pass (check unchanged, still meaningful)with check src/main.wok;with build :devand:stage2greenNot run here (per instructions):
:fixpoint,:test.