From fb31e86537dab922d91f37b8e4954e0bfa748932 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 1 Apr 2026 05:32:24 +0800 Subject: [PATCH] fixes #25632; errors incompatibility between {.error.} and {.exportc} pragmas in semProcAux (#25639) fixes #25632 fixes #25631 fixes #25630 This pull request introduces a compatibility check between the `{.error.}` and `{.exportc.}` pragmas in procedure declarations. Specifically, it prevents a procedure from being marked with both pragmas at the same time, as this combination is now considered invalid. Pragma compatibility enforcement: * Added a check in `semProcAux` (in `compiler/semstmts.nim`) to emit a local error if a procedure is declared with both `{.error.}` and `{.exportc.}` pragmas, preventing their incompatible usage. --- compiler/semstmts.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 7e07143837..285b84cfc7 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -2552,6 +2552,9 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind, if not hasProto: implicitPragmas(c, s, n.info, validPragmas) + if {sfError, sfExportc} * s.flags == {sfError, sfExportc}: + localError(c.config, n.info, "{.error.} and {.exportc.} pragmas are incompatible") + if n[pragmasPos].kind != nkEmpty and sfBorrow notin s.flags: setEffectsForProcType(c.graph, s.typ, n[pragmasPos], s) s.typ.incl tfEffectSystemWorkaround