feat(ffi-linkage): reject extern+export on one decl (Phase 4) — 1175 green

This commit is contained in:
agra
2026-06-14 16:06:22 +03:00
parent 847a027fb1
commit 422c6577cf

View File

@@ -2002,6 +2002,14 @@ pub const Parser = struct {
// Optional postfix linkage modifier: `extern` (import) / `export` (define).
const extern_export = self.parseOptionalExternExport();
// `extern` and `export` are mutually exclusive — one declaration is either
// an import or a definition, never both. Reject the redundant second keyword
// with a clear message rather than the bare "expected ';'" the body parser
// would otherwise emit.
if (extern_export != .none and (self.current.tag == .kw_extern or self.current.tag == .kw_export)) {
return self.fail("conflicting linkage: 'extern' and 'export' cannot be combined — a declaration is either an import ('extern') or a definition ('export')");
}
// Optional `[LIB] ["csym"]` tail after extern/export — a library-alias
// ident then a C symbol-name string, both optional (mirrors
// `#foreign LIB "csym"`). Stored on extern_lib/extern_name; the rename