fixes #24760; Noncopyable base type ignored (#24777)

fixes #24760

I tried `incl` `tfHasAsgn` to nontrivial assignment, but that solution
seems to break too many things. Instead, in this PR, `passCopyToSink`
now checks nontrivial assignment

(cherry picked from commit e958f4a3cd)
This commit is contained in:
ringabout
2025-09-22 16:50:57 +08:00
committed by narimiran
parent 5d3d8b52cd
commit 5724c685e9
4 changed files with 33 additions and 9 deletions

20
tests/arc/t24760.nim Normal file
View File

@@ -0,0 +1,20 @@
discard """
matrix: "--mm:orc"
errormsg: "=dup' is not available for type <B>, which is inferred from unavailable '=copy'; requires a copy because it's not the last read of 'b'; another read is done here: t24760.nim(19, 8); routine: g"
"""
type
A {.inheritable.} = object
B = object of A
proc `=copy`(a: var A, x: A) {.error.}
#proc `=copy`(a: var B, x: B) {.error.}
proc ffff(v: sink B) =
echo v
proc g() =
var b: B
ffff(b)
ffff(b)
g()