8000 `return n` is rejected in a `-> Integer?` function where a final `n` is accepted · Issue #774 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

return n is rejected in a -> Integer? function where a final n is accepted #774

Open

Description

@akoskovacs

In a function declared to return Integer?, the last expression n (an Integer) is accepted, but return n is not.

let viaReturn(text: String) -> Integer? do
  let n = Integer.parse(text).try
  return n
end

let viaLast(text: String) -> Integer? do
  let n = Integer.parse(text).try
  n
end
example.kex:3:10: [KEXET-0127]: Error, `viaReturn` declared to return Integer? but body returns Integer

viaLast checks clean and runs. Expected: both accepted, or both rejected. Also, the error is KEXET-0127 ("body returns"), where a wrong return would normally be KEXET-0124.

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