diff options
-rw-r--r-- | compiler/semstmts.nim | 9 | ||||
-rw-r--r-- | tests/types/texportgeneric.nim | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 75b575fd9..2df1c42b3 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1486,9 +1486,12 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) = # final pass if a[2].kind in nkCallKinds: incl a[2].flags, nfSem # bug #10548 - if sfExportc in s.flags and s.typ.kind == tyAlias: - localError(c.config, name.info, "{.exportc.} not allowed for type aliases") - + if sfExportc in s.flags: + if s.typ.kind == tyAlias: + localError(c.config, name.info, "{.exportc.} not allowed for type aliases") + elif s.typ.kind == tyGenericBody: + localError(c.config, name.info, "{.exportc.} not allowed for generic types") + if tfBorrowDot in s.typ.flags: let body = s.typ.skipTypes({tyGenericBody}) if body.kind != tyDistinct: diff --git a/tests/types/texportgeneric.nim b/tests/types/texportgeneric.nim new file mode 100644 index 000000000..9e6be2bb6 --- /dev/null +++ b/tests/types/texportgeneric.nim @@ -0,0 +1,8 @@ +discard """ + errormsg: "{.exportc.} not allowed for generic types" + line: 6 +""" + +type Struct[T] {.exportc.} = object + a:int + b: T \ No newline at end of file |