8000 `match`, `loop` and `next` are accepted as function names, then cannot be called · Issue #779 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

match, loop and next are accepted as function names, then cannot be called #779

Open

Description

@akoskovacs

Most keywords are rejected as a function name with KEXEP-0001 (while, when, return, break, then). Three get through, and the function they define cannot be called.

let match(n: Integer) -> Integer = n

main do
  IO.printLine(match(1))
end

The definition checks clean. The call is read as a match expression:

example.kex:4:24: [KEXEP-0078]: Error, expected 'do' after match subject, got )

let loop(n: Integer) -> Integer = n is accepted the same way.

next behaves differently depending on the form:

  • let next(n: Integer) -> Integer = n is rejected, but with KEXEP-0124, which says "cannot name a variable".
  • foul next -> Void = IO.printLine("x") is accepted. Calling it as next gives KEXES-0003: 'next' used outside a loop.

Expected: KEXEP-0001 at the definition for match, loop and next, in every form. Keywords as method names in a make block are allowed on purpose (#508), so this is only about top-level and module functions.

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

Activity

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

    BugSomething isn't workingParser

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0