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.

Exception while typechecking and compiling pattern matching with @

See original GitHub issue
object Fail {
  case class So[+T]()

  def main(args: Array[String]): Unit = {
    So[Int]() match {
      case p@So[_] => Console.println("Yep")
      case _       => Console.println("Nope")
    }
  }
}

Compiler says,

exception occurred while typechecking /path/to/Src.scala
exception occurred while compiling /path/to/Src.scala

Works well if underscore in pattern matching is replaced with a specific type.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
liufengyuncommented, Nov 16, 2016

@vuspenskiy Thanks for reporting, we’ll investigate the crash and why there’s no error message about syntax.

Regarding the syntax, we need to either use p : So[_] or p @ So(_) in the code example.

Following code has the same stack trace:

object Fail {
  def f(m: Option[Int]): Unit = {
     m match {
      case x @ Some[_] =>
      case _       =>
    }
  }
}
0reactions
liufengyuncommented, Dec 24, 2016

No worry @jvican , I’ll take care of it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clean code applied to .NET: avoid type checking with pattern ...
When data and methods are separate, you need other tools. The new pattern matching constructs enable cleaner syntax to examine data and ...
Read more >
Pattern Matching Support #165 - microsoft/TypeScript - GitHub
I've seen some short notions about pattern matching on code plex, ... build in an Ometa-like library that allowed you to do pattern...
Read more >
Typing and ML
constructs that restrict access to objects of a given type through a fixed set of ops defined for that type. Pattern matching. Function...
Read more >
3.10. Exceptions — OCaml Programming - GitHub Pages
The exception pattern exception (Failure s) matches that value. So the above code will evaluate to "hd" . In general, exception patterns are...
Read more >
Pattern Matching for Java — Semantics - OpenJDK
Type checking. Certain pattern matches can be rejected at compile time based strictly on static checks, such as: String s = "Hello"; if ......
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