ww imports: reject init bindings before recovery
This commit is contained in:
@@ -130,6 +130,9 @@ export type node = struct {
|
||||
usesource: str, // N_USE: immutable dotted source spelling
|
||||
usepath: str, // N_USE: canonical vendor-expanded identity
|
||||
usealias: str, // N_USE: explicit file-local alias, or empty
|
||||
usefile: str, // N_USE: first spec token (alias, otherwise path)
|
||||
useline: i32,
|
||||
usecol: i32,
|
||||
usepkgname: str,// N_USE: imported declared package name
|
||||
useblank: i32, // N_USE: `_` spelling; no source binding
|
||||
pkgname: str, // declared package name; independent of canonical nmod
|
||||
@@ -150,7 +153,7 @@ export fn newnode(k: nkind, file: str, line: i32, col: i32) *node = {
|
||||
// fval cast-init: 990's wwdump TK_FLOAT diff requires this file
|
||||
// to tokenise identically through C and ww (lex.ww:382 has the
|
||||
// same workaround for the cstage %g-formats vs ww-skips divergence).
|
||||
let n: *node = alloc(node{kind=k, file=file, line=line, col=col, op=tkind.TK_NONE, str="", uval=0u64, fval=0: f64, lhs=nil, rhs=nil, cond=nil, body=nil, els=nil, list=nil, next=nil, attr=nil, exported=0, packed=0, type_=nil, tsuffix="", nmod="", usesource="", usepath="", usealias="", usepkgname="", useblank=0, pkgname="", sourceid=0, used=0, initfn=0, initsynthetic=0, runtimeinit=0, initorder=0u64, linksym="", refdecl=nil, initmark=0u64, imported=0})!;
|
||||
let n: *node = alloc(node{kind=k, file=file, line=line, col=col, op=tkind.TK_NONE, str="", uval=0u64, fval=0: f64, lhs=nil, rhs=nil, cond=nil, body=nil, els=nil, list=nil, next=nil, attr=nil, exported=0, packed=0, type_=nil, tsuffix="", nmod="", usesource="", usepath="", usealias="", usefile="", useline=0, usecol=0, usepkgname="", useblank=0, pkgname="", sourceid=0, used=0, initfn=0, initsynthetic=0, runtimeinit=0, initorder=0u64, linksym="", refdecl=nil, initmark=0u64, imported=0})!;
|
||||
return n;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ fn parseuse(p: *parser) *node = {
|
||||
advance(p);
|
||||
let n: *node = newnode(nkind.N_USE, pf, pl, pc);
|
||||
n.nmod = p.curmod;
|
||||
// Keep the node position at the import keyword for structural diagnostics.
|
||||
// The binding error belongs to the first spec token, matching Go's alias-or-
|
||||
// path ImportDecl position.
|
||||
n.usefile = p.curfile;
|
||||
n.useline = p.curline;
|
||||
n.usecol = p.curcol;
|
||||
let alias: str;
|
||||
let first: str;
|
||||
if (p.curkind == tkind.TK_UNDER) {
|
||||
|
||||
Reference in New Issue
Block a user