--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Today I hit this:
scala> val (xs: List[scala.Int], _) = (List(5), 6)
<console>:1: error: ']' expected but '.' found.
val (xs: List[scala.Int], _) = (List(5), 6)
^
after an hour or so of coming up empty on IRC and in JIRA, thinking it
must be a bug but wanting to rule out other explanations, I eventually
found out about "type variable patterns" from SLS 8.2 and 8.3, and that
led me here:
Today I hit this:
scala> val (xs: List[scala.Int], _) = (List(5), 6)
<console>:1: error: ']' expected but '.' found.
val (xs: List[scala.Int], _) = (List(5), 6)
^
after an hour or so of coming up empty on IRC and in JIRA, thinking it
must be a bug but wanting to rule out other explanations, I eventually
found out about "type variable patterns" from SLS 8.2 and 8.3, and that
led me here:
http://stackoverflow.com/questions/7413671/scala-pattern-match-problem-with-fully-qualified-classnames-in-parameterization
Wow, so Scala has "type variable patterns". I had no idea, and neither
did a whole roomful of Scala programmers on IRC (*). All of the top
Google hits on this are either just on the spec, or are on people who
hit the same parsing issue I did. There are no JIRA issues that mention
"type variable pattern" except SI-4628 which doesn't really count (it's
about a minor spec update).
Is this the most obscure Scala feature ever...?
Does anyone use it...?
It'd be nice if the parser gave a better error message in this case.
(*) Except Tom Switzer, who says he used this in the Precog codebase.
Of course, where else? I invite him to reply with details.
--
Seth Tisue | Northwestern University | http://tisue.net
developer, NetLogo: http://ccl.northwestern.edu/netlogo/
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
On Tue, Nov 19, 2013 at 8:19 PM, Seth Tisue <se...@tisue.net> wrote:
It'd be nice if the parser gave a better error message in this case.Indeed. I would classify it as a bug. In fact, the parser should not issue an error at all, but simply parse the whole type.
Agreed, that would be consistent withscala> Nil match { case scala.Nil => }I've lodged a ticket: https://issues.scala-lang.org/browse/SI-7985
-jason
That was quick! But I believe it might be better to attack the problem more at the root. The problem with the patch is thatcase Array[a[b]]would still be rejected by the parser with the obscure error message. Why not just read a full type regardless and then inspect the resulting tree to see whether it represents a variable (lower-case) ident? That would be analogous to what we do with term ids, I believe.