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
{{ message }}
Repository navigation
sum over [Integer] is typed Number, so it cannot be returned as Integer #752
sum over a list of integers is typed Number, so a function that sums integers cannot declare -> Integer:
record Item do
count : Integer
end
let total(items: [Item]) -> Integer = items.map { |i| i.count }.sum
sum.kex:5:68: [KEXET-0127]: Error, `total` declared to return Integer but body returns Number
The element type is not the problem: kex -C -t on [1, 2, 3].map { |x| x * 2 }.sum types the mapped list as [Integer] and only the .sum as Number.
Expected:sum over [Integer] is Integer (and over [Float] is Float), i.e. its result is the element type, or at least Integer is accepted where the declared result is Integer.
Seen on 0.4.0-rc.4 (0292db50), macOS arm64, OTP 29.
Activity