-
-
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.
generate destructor in nodestroy proc for explicit destructor call (#…
…24627) fixes #24626 `createTypeboundOps` in sempass2 is called when generating destructors for types including for explicit destructor calls, however it blocks destructors from getting generated in a `nodestroy` proc. This causes issues when a destructor is explicitly called in a `nodestroy` proc. To fix this, allow destructors to get generated only for explicit destructor calls in nodestroy procs. (cherry picked from commit 793baf3)
- Loading branch information
Showing
2 changed files
with
28 additions
and
3 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 @@ | ||
discard """ | ||
ccodecheck: "'Result[(i - 0)] = eqdup'" | ||
""" | ||
|
||
# issue #24626 | ||
|
||
proc arrayWith2[T](y: T, size: static int): array[size, T] {.noinit, nodestroy, raises: [].} = | ||
## Creates a new array filled with `y`. | ||
for i in 0..size-1: | ||
when defined(nimHasDup): | ||
result[i] = `=dup`(y) | ||
else: | ||
wasMoved(result[i]) | ||
`=copy`(result[i], y) | ||
|
||
proc useArray(x: seq[int]) = | ||
var a = arrayWith2(x, 2) | ||
|
||
proc main = | ||
let x = newSeq[int](100) | ||
for i in 0..5: | ||
useArray(x) | ||
|
||
main() |