You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Overloading resolution works as expected when the proc definition and the proc call are in the same file.
However there are conflicts when proc is called from another module.
It might be as "intended" from the manual
Rule #3: Generic match: f is a generic type and a matches, for instance a is int and f is a generic (constrained) parameter type (like in [T] or [T: int|char].
but this prevents specializing proc like $ for typeclass and maybe concepts:
Test case in 2 files
# Filename: test1.nimtypeMatrix*[M, N: static[int], T: SomeReal] =object
data: refarray[N * M, T]
Matrix32*[M, N: static[int]] =Matrix[M, N, float32]
Matrix64*[M, N: static[int]] =Matrix[M, N, float64]
proczeros*(M,N: static[int], T: typedesc[float64]): Matrix[M,N,T] =newresult.data
for i in0..< (M * N):
result.data[i] =0proc`$`*[M, N: static[int]](m: Matrix32[M, N] orMatrix64[M, N]): string=result="Matrix["&$M &", "&$N &"]"
File2
import test1
procbaz*[T](a: T) =echo a
let a =zeros(2,2, float64)
baz(a)
Error
ambiguous call; both system.$(x: T) and test1.$(m: Matrix32[$.M, $.N] or Matrix64[$.M, $.N]) match for: (Matrix[2, 2, system.float64])
The text was updated successfully, but these errors were encountered:
Related to #5644, #1991 and commit f8c921d.
Overloading resolution works as expected when the proc definition and the proc call are in the same file.
However there are conflicts when proc is called from another module.
It might be as "intended" from the manual
but this prevents specializing proc like
$
for typeclass and maybe concepts:Test case in 2 files
File2
Error
The text was updated successfully, but these errors were encountered: