mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-25 00:35:26 +00:00
fix generic converter subtype match regression (#25015)
fixes #25014
`implicitConv` tries to instantiate the supertype to convert to,
previously the bindings of `m` was shared with the bindings of the
converter but now an isolated match `convMatch` holds the bindings, so
`convMatch` is now used in the call to `implicitConv` instead of `m` so
that its bindings are used when instantiating the supertype.
(cherry picked from commit 97a6f42b56)
This commit is contained in:
14
tests/converter/tgenericsubtypeconverter.nim
Normal file
14
tests/converter/tgenericsubtypeconverter.nim
Normal file
@@ -0,0 +1,14 @@
|
||||
# issue #25014
|
||||
|
||||
type
|
||||
FooBase[T] {.inheritable.} = object
|
||||
val: T
|
||||
FooChild[T] = object of FooBase[T]
|
||||
|
||||
converter toValue*[T](r: FooBase[T]): T = r.val
|
||||
|
||||
proc foo(a: int) = discard
|
||||
var f: FooChild[int]
|
||||
foo(f)
|
||||
proc fooGeneric[T](a: T) = discard
|
||||
fooGeneric(f)
|
||||
Reference in New Issue
Block a user