better overloading resolution for generics

This commit is contained in:
Araq 2013-02-28 21:28:19 +01:00
commit d13bcf6575
4 changed files with 65 additions and 19 deletions

20
tests/run/toverl3.nim Executable file
View file

@ -0,0 +1,20 @@
discard """
file: "toverl3.nim"
output: '''m1
tup1'''
"""
# Tests more specific generic match:
proc m[T](x: T) = echo "m2"
proc m[T](x: var ref T) = echo "m1"
proc tup[S, T](x: tuple[a: S, b: ref T]) = echo "tup1"
proc tup[S, T](x: tuple[a: S, b: T]) = echo "tup2"
var
obj: ref int
tu: tuple[a: int, b: ref bool]
m(obj)
tup(tu)

View file

@ -1,16 +0,0 @@
discard """
file: "toverlop.nim"
output: "3"
"""
# Test operator overloading
proc `%` (a, b: int): int =
return a mod b
var x, y: int
x = 15
y = 6
write(stdout, x % y)
#OUT 3