mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-10 15:04:59 +00:00
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:
@@ -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:
|
||||
|
||||
8
tests/types/texportgeneric.nim
Normal file
8
tests/types/texportgeneric.nim
Normal file
@@ -0,0 +1,8 @@
|
||||
discard """
|
||||
errormsg: "{.exportc.} not allowed for generic types"
|
||||
line: 6
|
||||
"""
|
||||
|
||||
type Struct[T] {.exportc.} = object
|
||||
a:int
|
||||
b: T
|
||||
Reference in New Issue
Block a user