A function missing a clause passes the checker; BEAM crashes with `function_clause`, the walker silently returns nothing · Issue #749 · kexhq/kex · GitHub
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 function missing a clause passes the checker; BEAM crashes with function_clause, the walker silently returns nothing #749
A multi-clause function whose patterns don't cover its argument type is accepted, and the two backends then disagree about what happens.
type Shape = Circle(Float) | Square(Float)
let area(Circle(r)) = 3.0 * r * r
main do
IO.printLine(area(Square(2.0)))
end
result
kex -C
No errors found.
kex (BEAM)
Internal error: function_clause, exit 1
kex -R
prints an empty line, exit 0
Expected: a compile error, as for a non-exhaustive match over the same ADT (spec/error_exhaustive_adt.kex): area has no clause for Square. Failing that, both backends should at least fail the same way at run time; the walker returning nothing hides the bug.
Related: #645 (pattern-matrix exhaustiveness for tuple, literal and list patterns) is about match, not the clauses of a function.
Seen on 0.4.0-rc.4 (0292db50), macOS arm64, OTP 29.
Activity