From 422c6577cf9a251b8fd2ca52cda52c733036a37a Mon Sep 17 00:00:00 2001 From: agra Date: Sun, 14 Jun 2026 16:06:22 +0300 Subject: [PATCH] =?UTF-8?q?feat(ffi-linkage):=20reject=20extern+export=20o?= =?UTF-8?q?n=20one=20decl=20(Phase=204)=20=E2=80=94=201175=20green?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parser.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/parser.zig b/src/parser.zig index d3df6f1..305d078 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -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