8000 `return Error(...)` passes the checker in a function declared to return `Integer` · Issue #768 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

return Error(...) passes the checker in a function declared to return Integer #768

Open

Description

@akoskovacs

A return of an Error is not checked against a plain return type.

let parse(text: String) -> Integer do
  return Error("bad") if text.empty?
  1
end

main do
  IO.printLine(parse("") + 1)
end
  • kex -C: No errors found.
  • kex -R: runtime error: cannot add Result<?, String> and Integer at the + 1.
  • kex (BEAM): Internal error: badarith

The checker believes parse answers an Integer, so the Error comes out at the caller. Expected: KEXET-0124, as for return "text" in the same place. This may be the postfix-return case from #723 again, but with a constructor in place of a literal.

Seen on kex 0.4.0-rc.4 built from main at 371bbdf, and on 5773911. Found while writing explanations for oops.kex.run.

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