fixes compiler crash by preventing exportc on generics (#22731)

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
(cherry picked from commit fefde3a735)
This commit is contained in:
Juan M Gómez
2023-09-20 07:19:29 +01:00
committed by narimiran
parent d56000eaff
commit e918a762f7
2 changed files with 14 additions and 3 deletions

View File

@@ -1483,9 +1483,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:

View File

@@ -0,0 +1,8 @@
discard """
errormsg: "{.exportc.} not allowed for generic types"
line: 6
"""
type Struct[T] {.exportc.} = object
a:int
b: T