Open
Description
Description
When builtin types have generics, chaining distincts causes improper proc resolution.
This doesn't work
type
MyType[T] = seq[T]
A[T] = distinct MyType[T]
B[T] = distinct A[T]
proc doThing[T](a: var A[T]) = discard
proc doThing[T](b: var B[T]) = A[T](b).doThing()
var a = B[int].default
doThing(a)
Nim Version
Nim Compiler Version 2.0.0 [Windows: amd64]
Compiled at 2023-08-01
Copyright (c) 2006-2023 by Andreas Rumpf
active boot switches: -d:release
Current Output
d:\dump\Git\Finnese\src\isuse.nim(12, 8) template/generic instantiation of `doThing` from here
d:\dump\Git\Finnese\src\isuse.nim(8, 39) Error: type mismatch
Expression: doThing(A[T](b))
[1] A[T](b): A[system.int]
Expected one of (first mismatch at [position]):
[1] proc doThing[T](a: var A[T])
[1] proc doThing[T](b: var B[T])
Expected Output
None
Possible Solution
No response
Additional Information
Changing the base type to an object works
type
MyType[T] = object
a: T
A[T] = distinct MyType[T]
B[T] = distinct A[T]
proc doThing[T](a: var A[T]) = discard
proc doThing[T](b: var B[T]) = A[T](b).doThing()
var a = B[int].default
doThing(a)
As does removing the generic parameters and hard coding a type instead.