whats strange is that if you just copy the function from math to current module
it will raise properly.
type Probability = range[0.0..1.0]
proc sum*[T](x: openArray[T]): T {.noSideEffect.} =
## Computes the sum of the elements in ``x``.
##
## If ``x`` is empty, 0 is returned.
##
## See also:
## * `prod proc <#prod,openArray[T]>`_
## * `cumsum proc <#cumsum,openArray[T]>`_
## * `cumsummed proc <#cumsummed,openArray[T]>`_
runnableExamples:
doAssert sum([1, 2, 3, 4]) == 10
doAssert sum([-1.5, 2.7, -0.1]) == 1.1
for i in items(x): result = result + i
let ps = @[Probability 0.5, 0.5, 0.5]
# The following line raises properly
echo "Using math sum: ", sum(ps), " typeof: ", typeof(sum(ps))
Run