8000 A function missing a clause passes the checker; BEAM crashes with `function_clause`, the walker silently returns nothing · Issue #749 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

A function missing a clause passes the checker; BEAM crashes with function_clause, the walker silently returns nothing #749

Open

Description

@akoskovacs

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0