-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix nil node in sym ast of exported ref objects [backport:2.2] (#24527)
fixes #24526, follows up #23101 The `shallowCopy` calls do not keep the original node's children, they just make a new seq with the same length, so the `Ident "*"` node from the original postfix nodes was not carried over, making it `nil` and causing the segfault.
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# issue #24526 | ||
|
||
import std/macros | ||
|
||
template prag {.pragma.} | ||
|
||
type | ||
Foo1* = ref object of RootObj | ||
name*: string | ||
Foo2* {.used.} = ref object of RootObj | ||
name*: string | ||
Foo3* {.prag.} = ref object of RootObj | ||
name*: string | ||
Foo4* {.used, prag.} = ref object of RootObj | ||
name*: string | ||
|
||
# needs to have `typedesc` type | ||
proc foo(T: typedesc): bool = | ||
T.hasCustomPragma(prag) | ||
|
||
doAssert not foo(typeof(Foo1()[])) | ||
doAssert not foo(typeof(Foo2()[])) | ||
doAssert foo(typeof(Foo3()[])) | ||
doAssert foo(typeof(Foo4()[])) |