diff options
author | metagn <metagngn@gmail.com> | 2023-09-06 05:45:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-06 05:45:07 +0300 |
commit | 90f87bcab769f3555454bbd210129670767cffbf (patch) | |
tree | 1b49056011c84f3daf1f3e46460bf12bb2ac0421 /tests/distinct | |
parent | eb91cf991aa9840639cc358c21d503e4cf27e268 (diff) | |
download | Nim-90f87bcab769f3555454bbd210129670767cffbf.tar.gz |
fully revert generic inst sym change, test #22646 (#22653)
reverts #22642, reopens #22639, closes #22646, refs #22650, refs https://github.com/alaviss/union/issues/51, refs #22652 The fallout is too much from #22642, we can come back to it if we can account for all the affected code.
Diffstat (limited to 'tests/distinct')
-rw-r--r-- | tests/distinct/tborrow.nim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/distinct/tborrow.nim b/tests/distinct/tborrow.nim index 8a40982a8..e34248de5 100644 --- a/tests/distinct/tborrow.nim +++ b/tests/distinct/tborrow.nim @@ -98,3 +98,35 @@ block: # issue #22069 MuscleCar = Car[128] var x: MuscleCar doAssert x.color is array[128, int] + +block: # issue #22646 + type + Vec[N : static[int], T: SomeNumber] = object + arr: array[N, T] + Vec3[T: SomeNumber] = Vec[3, T] + + proc `[]=`[N,T](v: var Vec[N,T]; ix:int; c:T): void {.inline.} = v.arr[ix] = c + proc `[]`[N,T](v: Vec[N,T]; ix: int): T {.inline.} = v.arr[ix] + + proc dot[N,T](u,v: Vec[N,T]): T {. inline .} = discard + proc length[N,T](v: Vec[N,T]): T = discard + proc cross[T](v1,v2:Vec[3,T]): Vec[3,T] = discard + proc normalizeWorks[T](v: Vec[3,T]): Vec[3,T] = discard ## <- Explicit size makes it work! + proc foo[N,T](u, v: Vec[N,T]): Vec[N,T] = discard ## <- broken + proc normalize[N,T](v: Vec[N,T]): Vec[N,T] = discard ## <- broken + + type Color = distinct Vec3[float] + + template borrowOps(typ: typedesc): untyped = + proc `[]=`(v: var typ; ix: int; c: float): void {.borrow.} + proc `[]`(v: typ; ix: int): float {.borrow.} + proc dot(v, u: typ): float {.borrow.} + proc cross(v, u: typ): typ {.borrow.} + proc length(v: typ): float {.borrow.} + proc normalizeWorks(v: typ): typ {.borrow.} ## Up to here everything works + proc foo(u, v: typ): typ {.borrow.} ## Broken + proc normalize(v: typ): typ {.borrow.} ## Broken + borrowOps(Color) + var x: Vec[3, float] + let y = Color(x) + doAssert Vec3[float](y) == x |