build: close package variant identity gaps
This commit is contained in:
@@ -312,7 +312,9 @@ fn lookupvisibletype(c: *checker, name: str) *syntax.sym = {
|
||||
for (b != nil) {
|
||||
if (b.skind == syntax.skind.SK_TYPE
|
||||
&& syntax.streq(b.name, name)
|
||||
&& directmodvisible(c, b.mod)) { return b; };
|
||||
&& directmodvisible(c, b.mod)
|
||||
&& (b.decl == nil || b.decl.imported == 0
|
||||
|| b.decl.exported != 0)) { return b; };
|
||||
b = b.snext;
|
||||
};
|
||||
p = p.parent;
|
||||
|
||||
@@ -1397,6 +1397,15 @@ fn sepaddgeneratedmain(g: *sepgraph, product: *sepproduct, ordinal: i32,
|
||||
if (variant < 0 || variant >= g.n) { return -1; };
|
||||
let p: *seppkg = &g.pkg[g.n];
|
||||
p.path = generatedmainpath(ordinal);
|
||||
let pathi: i32 = 0;
|
||||
for (pathi < g.n) {
|
||||
if (cstreq(g.pkg[pathi].path, p.path)) {
|
||||
cerr("ww: generated test-main package identity collides with source import ");
|
||||
cerr(pathstr(p.path)); cerr("\n");
|
||||
return -1;
|
||||
};
|
||||
pathi += 1;
|
||||
};
|
||||
p.entry = g.pkg[variant].entry;
|
||||
p.artifact = productartifact(ordinal, SEP_VARIANT_TEST_MAIN);
|
||||
p.name = arenadupcstr("main\0".ptr, 4u64);
|
||||
@@ -1613,6 +1622,20 @@ fn septopovisit(g: *sepgraph, pi: i32, order: []i32, no: *i32,
|
||||
return 0;
|
||||
};
|
||||
|
||||
fn sepinternalreplacesproduction(g: *sepgraph, a: i32, b: i32) bool = {
|
||||
let internal: i32 = a;
|
||||
let production: i32 = b;
|
||||
if (g.pkg[internal].variant != SEP_VARIANT_SAME_TEST) {
|
||||
internal = b;
|
||||
production = a;
|
||||
};
|
||||
return g.pkg[internal].variant == SEP_VARIANT_SAME_TEST
|
||||
&& g.pkg[production].variant == SEP_VARIANT_PRODUCTION
|
||||
&& g.pkg[production].role != SEP_ROLE_TEST_SUPPORT
|
||||
&& os.samefile(pathstr(g.pkg[internal].entry),
|
||||
pathstr(g.pkg[production].entry));
|
||||
};
|
||||
|
||||
fn sepvalidatemoduleclosure(g: *sepgraph, order: []i32, n: i32,
|
||||
includeroot: bool) i32 = {
|
||||
let i: i32 = 0;
|
||||
@@ -1624,7 +1647,8 @@ fn sepvalidatemoduleclosure(g: *sepgraph, order: []i32, n: i32,
|
||||
for (j < n) {
|
||||
let b: i32 = order[j];
|
||||
if ((includeroot || !g.pkg[b].root)
|
||||
&& cstreq(g.pkg[a].path, g.pkg[b].path)) {
|
||||
&& cstreq(g.pkg[a].path, g.pkg[b].path)
|
||||
&& !sepinternalreplacesproduction(g, a, b)) {
|
||||
cerr("ww: product closure contains multiple packages named ");
|
||||
cerr(pathstr(g.pkg[a].path)); cerr("\n");
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user