wip(E4): partial source-pin + non-transitive flip [stdlib E4 attempt-1 WIP checkpoint]

Incomplete WIP from a worker killed at the 55-min wall (large blast radius:
core source-pin + ~8 example migrations + ~10 library module migrations).
Committed so the resumed session continues on a clean tree. May not build.
This commit is contained in:
agra
2026-06-08 11:12:08 +03:00
parent 4d539eeacd
commit 33a6f5c650
28 changed files with 202 additions and 58 deletions

View File

@@ -1,4 +1,5 @@
#import "modules/std.sx";
#import "modules/allocators.sx"; // `Allocator` is non-transitive: name it, import it.
#import "modules/math/math.sx";
#import "modules/compiler.sx";
#import "modules/test.sx";

View File

@@ -13,6 +13,9 @@
// both impl modules.
#import "modules/std.sx";
// `Wrap` is declared in the shared types module; bare-import visibility is
// non-transitive, so naming it here means importing it here (not via impl-a/b).
#import "./0411-protocols-impl-duplicate-types.sx";
#import "./0411-protocols-impl-duplicate-impl-a.sx";
#import "./0411-protocols-impl-duplicate-impl-b.sx";

View File

@@ -9,6 +9,9 @@
// registration tripped: `duplicate impl 'Into' for source 's64'`. Now the flat
// decl list also dedups by node identity, so this builds and prints 7.
#import "modules/std.sx";
// `Wrapped` lives in the shared `common.sx`; bare-import visibility is
// non-transitive, so naming it here means importing it here (not via mid_a/b).
#import "0709-modules-issue-0056/common.sx";
#import "0709-modules-issue-0056/mid_a.sx";
#import "0709-modules-issue-0056/mid_b.sx";

View File

@@ -18,6 +18,7 @@
// and freed in one `deinit`; the writer path allocates nothing.
#import "modules/std.sx";
#import "modules/allocators.sx"; // `Allocator` is non-transitive: name it, import it.
#import "modules/std/json.sx";
#import "modules/fs.sx";

View File

@@ -20,6 +20,7 @@
// `JsonParseError` variant on the error channel, never a bogus value.
#import "modules/std.sx";
#import "modules/allocators.sx"; // `Allocator` is non-transitive: name it, import it.
#import "modules/std/json.sx";
// Canonical document: no insignificant whitespace, escapes in the writer's

View File

@@ -23,6 +23,7 @@
// and decoded strings go through `alloc`, and the writer allocates nothing.
#import "modules/std.sx";
#import "modules/allocators.sx"; // `Allocator` is non-transitive: name it, import it.
#import "modules/std/json.sx";
// The writer's EXACT output for the PART A document (insertion order,

View File

@@ -12,6 +12,7 @@
// independent identities.
#import "modules/std.sx";
#import "modules/allocators.sx"; // `Allocator` is non-transitive: name it, import it.
// `cli` is imported BOTH flat (so its types — `FlagSpec` / `Command` / `Diag` —
// are bare-visible) AND namespaced (so the same-name `cli.parse` stays a
// distinct qualified identity from `json.parse`). Post-E1 a bare reference to a

View File

@@ -0,0 +1,20 @@
// `#import` is non-transitive for TYPES, exactly like values/functions (0706):
// when A imports B and B imports C, A must NOT see C's top-level TYPE names.
// This file imports `b.sx` (which in turn imports `c.sx`) and then references
// C's type `COnly` directly — the compiler rejects it with a
// "type ... is not visible; #import the module that declares it" diagnostic.
//
// `b.sx` ↔ `c.sx` together still compile: `b_make`'s return type `COnly`
// resolves because b.sx directly imports c.sx.
//
// Regression (Phase E4): before the bare-TYPE gate went single-hop this
// 2-flat-hop type was wrongly visible (the interim transitive closure).
#import "modules/std.sx";
#import "0763-modules-import-type-non-transitive/b.sx";
main :: () -> s32 {
x : COnly = .{ v = 5 };
print("{}\n", x.v);
0
}

View File

@@ -0,0 +1,7 @@
#import "c.sx";
// b.sx directly imports c.sx, so it CAN name `COnly` — proving the type is
// only one flat hop away here, two hops away from a file that imports b.sx.
b_make :: () -> COnly {
.{ v = 99 }
}

View File

@@ -0,0 +1 @@
COnly :: struct { v: s64 = 0; }

View File

@@ -4,6 +4,7 @@
// whether the recovery happens BEFORE or AFTER the first dispatch.
#import "modules/std.sx";
#import "modules/allocators.sx"; // `Allocator` is non-transitive: name it, import it.
main :: () -> s32 {
gpa := GPA.init();

View File

@@ -9,6 +9,7 @@
// the operand's storage, so it never allocates and never reaches this
// path. See specs.md §3 — Protocol value ownership and lifetime.
#import "modules/std.sx";
#import "modules/allocators.sx"; // `Allocator` is non-transitive: name it, import it.
Tracer :: struct {
count: s64;

View File

@@ -1,5 +1,5 @@
error: duplicate xx conversion from 's64' to 'Wrap': impls in /Users/agra/projects/sx/examples/./0411-protocols-impl-duplicate-impl-a.sx and /Users/agra/projects/sx/examples/./0411-protocols-impl-duplicate-impl-b.sx
--> /Users/agra/projects/sx/examples/0411-protocols-impl-duplicate.sx:20:17
--> /Users/agra/projects/sx/examples/0411-protocols-impl-duplicate.sx:23:17
|
20 | w : Wrap = xx 7;
23 | w : Wrap = xx 7;
| ^

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,5 @@
error: type 'COnly' is not visible; #import the module that declares it
--> /Users/agra/projects/sx/examples/0763-modules-import-type-non-transitive.sx:17:9
|
17 | x : COnly = .{ v = 5 };
| ^^^^^