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
Checker accepts Option<T> where T is expected (let annotation and call args) #611
All three pass `kex -C` with `No errors found` (`kex 0.4.0-rc.3 (78af651)`):
main do
let x: Integer = Just(0) # let annotation, Just
IO.printLine(x)
end
main do
let x: Integer = None # let annotation, None
IO.printLine(x)
end
let pick(n: Integer) -> Integer = n
main do
IO.printLine(pick(Just(5))) # call argument
end
Contrast: `let x: Integer = "hi"` correctly reports `error: Type mismatch: expected Integer, got String`, so annotations are enforced in general — `Option` specifically seems compatible with `T`.
Runtime consequence: the mistyped value flows through, e.g. `pair[0] + pair[1]` on `Option` operands reaches the backends (walker: `runtime error: Cannot add Optional and Optional` with a location; BEAM: a bare `Internal error: function_clause`). Found while drafting Rosetta Code entries.
Another variant, still present on kex 0.4.0-rc.3 (266b7a60): an optional variable passed as a call argument.
let double(n: Integer) -> Integer = n * 2
main do
let maybe: Integer? = None
IO.printLine("${double(maybe)}")
end
Accepted; fails at run time with badarith.
The cause is a branch in argMatchesParam that unwraps an optional argument and retries against the bare parameter (src/semantic/typechecker_expr.cxx:3519-3521).
Activity
akoskovacs commentedon Nov 12, 2026
Another variant, still present on
kex 0.4.0-rc.3 (266b7a60): an optional variable passed as a call argument.Accepted; fails at run time with
badarith.The cause is a branch in
argMatchesParamthat unwraps an optional argument and retries against the bare parameter (src/semantic/typechecker_expr.cxx:3519-3521).