jakt icon indicating copy to clipboard operation
jakt copied to clipboard

parser: Error for invalid match patterns is not clear/actionable

Open cg-jl opened this issue 2 years ago • 4 comments

The parser fails with expected '=>' after pattern case if a case is a byte literal:

function main() {
  match b'.' {
    b';' => 0
    else => 1
  }
}

cg-jl avatar May 25 '22 13:05 cg-jl

Match only accepts values as (expr) =>, right now only variant names are allowed without parenthesis:

function main() {
  match b'.' {
    (b';') => 0
    else => 1
  }
}

alimpfard avatar May 25 '22 16:05 alimpfard

oh okay, thank you. Should we leave this or close this?

cg-jl avatar May 25 '22 17:05 cg-jl

The error should be more clear at the very least, and the syntax is still fairly experimental (like most of the language :P), so we can leave the issue open for "improve error message"

alimpfard avatar May 25 '22 17:05 alimpfard

Since https://github.com/SerenityOS/jakt/commit/b0b7bddf6015319342418b43dd9c3ad3ce5102bd bare literals are accepted, so looks like this is not an issue anymore

cg-jl avatar Jun 04 '22 08:06 cg-jl