From 7c5ae008874e7bb76214bca96267bcb400a723d1 Mon Sep 17 00:00:00 2001 From: Neelesh Chandola Date: Thu, 3 Jan 2019 00:31:06 +0530 Subject: [PATCH] exportc is now not allowed for type aliases (#9979) --- compiler/semstmts.nim | 2 ++ tests/pragmas/t5149.nim | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/pragmas/t5149.nim diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 59eb231628..39f200ba86 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1101,6 +1101,8 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) = #debug s.typ s.ast = a popOwner(c) + if sfExportc in s.flags and s.typ.kind == tyAlias: + localError(c.config, name.info, "{.exportc.} not allowed for type aliases") let aa = a.sons[2] if aa.kind in {nkRefTy, nkPtrTy} and aa.len == 1 and aa.sons[0].kind == nkObjectTy: diff --git a/tests/pragmas/t5149.nim b/tests/pragmas/t5149.nim new file mode 100644 index 0000000000..2d242a8d5f --- /dev/null +++ b/tests/pragmas/t5149.nim @@ -0,0 +1,12 @@ +discard """ + errormsg: "{.exportc.} not allowed for type aliases" + line: 9 +""" + +type + X* = object + a: int + Y* {.exportc.} = X + +proc impl*(x: X) = + echo "it works"