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
A postfix return x if cond is not checked against the declared return type #723
A return in the postfix-if form isn't checked against the function's declared return type. The block form is checked.
let label(n: Integer) -> Integer do
return "negative" if n < 0
n
end
main do
let x = label(-1)
IO.printLine(x + 1)
end
kex -C: No errors found.
kex --run-walker: runtime error: cannot add String and Integer at the x + 1.
kex (BEAM): Internal error: badarith.
The checker believes label answers an Integer, so the String comes out at the caller, far from where it was returned.
The same return written as a block is rejected, as expected:
let plain(n: Integer) -> Integer do
if n < 0
return "negative"
end
n
end
8:5: [KEXET-0124]: Error, `plain` declared to return Integer but returns String here
So KEXET-0124's check reaches a return inside an if block, but not a return that is the body of a postfix if. Expected: the postfix form reports KEXET-0124 at the return too.
Activity