fixes #3329
This commit is contained in:
parent
432884861e
commit
36f68e1650
7 changed files with 65 additions and 17 deletions
22
tests/typerel/t2plus.nim
Normal file
22
tests/typerel/t2plus.nim
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
discard """
|
||||
output: "2.0"
|
||||
"""
|
||||
|
||||
{.warning[TypelessParam]: off.}
|
||||
|
||||
import future
|
||||
|
||||
# bug #3329
|
||||
|
||||
proc foldRight[T,U](lst: seq[T], v: U, f: (T, U) -> U): U =
|
||||
result = v
|
||||
for x in lst:
|
||||
result = f(x, result)
|
||||
|
||||
proc mean[T: SomeNumber](xs: seq[T]): T =
|
||||
xs.foldRight(0.T, (xBAZ: auto, yBAZ: auto) => xBAZ + yBAZ) / T(xs.len)
|
||||
|
||||
when isMainModule:
|
||||
let x = mean(@[1.float, 2, 3])
|
||||
echo x
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue