question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Semicolon does not parse in match types

See original GitHub issue

Compiler version

3.0.1

Minimized code

def Choice = (_: Any) match { case Int => Long; case Long => Int } // ok

type Choice[A] = A match { case Int => Long ; case Long => Int } // error

https://scastie.scala-lang.org/popPHRHGRTmfZ9n41Un3fQ

Output

'}' expected, but ';' found

Illegal start of toplevel definition

Expectation

Expected the semicolon to separate match type cases the same as for value matches. Couldn’t find a previous discussion on this, so I assume this is not intended?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
neko-kaicommented, Aug 19, 2021

But maybe the “least surprises” strategy would be to allow it in both cases since we cannot forbid it in the term match case.

I agree, but I was also surprised because I’ve had an intuition that semicolons and newlines were usually interchangeable as separators. The semicolon in a term match being a property of the block and not a separator on its own wasn’t something I thought about.

The idiomatic style is to leave semicolons out in both cases.

I agree, but the reason I’ve tried this is because that’s the only way to write a match in one line in REPL.

1reaction
oderskycommented, Aug 19, 2021

I actually can’t verify that, as it looks like the last BlockResult can be preceded by semicolon-terminated statements, but the BlockResult can’t end with a semicolon?

But the BlockResult is itself optional.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Regex to match strings if a line doesnot contain semicolon at ...
I want to match some strings that doesnot contain any semicolon at the end of a line or middle of the matched Strings....
Read more >
Guidelines For Using Semicolons & commas - Rust Users Forum
The comma is just for separating multiple cases in the match. Note that this match actually produces a value.
Read more >
python - Regex to parse semicolon-delimited fields is too slow
As a general rule if you can, try to avoid non-greedy matches(i.e. the ? in .*? ). The regexes are easier to match...
Read more >
SyntaxError: missing ; before statement - JavaScript | MDN
The JavaScript exception "missing ; before statement" occurs when there is a semicolon ( ; ) missing somewhere and can't be added by...
Read more >
The revised syntax - The Caml language
In revised syntax, simple semicolons end the items of structures, signatures and objects. These semicolons are mandatory. The double semicolon is no more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found