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.

Pattern-matching on Result produces a (spurious?) warning

See original GitHub issue

Issue Description

When my code tries to match on the result of a parse, such as:

    dumpfileP.parse(mySQL) match {
      case Result.Success(stmts, _) => stmts
      case Result.Failure(parser, index) => displayFailure(...)

The Scala compiler consistently kicks out a warning:

[warn] /home/jducoeur/GitHub/Querki/querki/scalajvm/app/querki/imexport/MySQLImport.scala:143: The outer reference in this type test cannot be checked at run time.
[warn]       case Result.Success(stmts, _) => stmts

This warning may be correct – I’m honestly unsure – but I don’t care about it, and definitely don’t want to see it. My coding standards are “no warnings”, so this is getting in the way of using FastParse for production code.

This can be worked around by using isInstanceOf + asInstanceOf, but that’s rather boilerplatey. A more idiomatic-Scala solution would be preferable.

Issue Analytics

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

github_iconTop GitHub Comments

aradkecommented, Feb 22, 2016

In versions 0.2.x I had to use import fastparse.core.Result In versions 0.3.x I had to use import fastparse.core.Parsed

To fix the compiler error: “The outer reference in this type test cannot be checked at run time.

(This is was using Scala 2.11.7 on the JVM with Java7.)

nebasukecommented, Feb 10, 2016

Had the same problem. import fastparse.core.Result fixed it for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Match Exhaustiveness Testing Ignores Guard Statements #5365
There are cases today when you get a spurious warning: if you know more than the compiler about the possible values that can...
Read more >
4. Pattern Matching - Programming Scala, 2nd Edition [Book]
So, it warns that the match isn't exhaustive. Then we see what happens when we try to match on a value for which...
Read more >
Warnings for pattern matching - Moscova
We examine the ML pattern-matching anomalies of useless clauses and non-exhaustive matches. We state the definition of these anomalies, building upon pattern ...
Read more >
Strange pattern-matching: is it correct? - haskell - Stack Overflow
It always returns True with any values and any types. Is this the correct behavior? The b in b -> True is a...
Read more >
Pattern matching using the is and switch expressions.
The compiler generates a warning if a switch expression doesn't handle all possible input values.
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 Post

No results found

github_iconTop Related Hashnode Post

No results found