[#196] | project: compiler | priority: medium | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Matthias | Burak | fixed | 2003-10-15 11:57:51.0 | |
subject | Empty sequence pattern yields NullPointerException | |||
code |
object Foo with Executable { def test(xs: List[Any]) = xs match { case List(b@()) => Console.println("b = " + b); } test(List(1)); } |
|||
what happened | Crashes at runtime:Exception in thread "main" java.lang.ExceptionInInitializerError at Foo.main(K.scala) Caused by: java.lang.NullPointerException at Foo$.test(K.scala:3) at Foo$. |
|||
what expected | Fails at runtime with a MatchError. | |||
[back to overview] |
Burak edited on 2003-10-29 15:28:36.0 |
Although this pattern was generated by your code Matthias (it does not contain | or *), it is a regular expression, so I took care of it. (TestRegTraverser did not handle empty sequences). The current hack-ish solution is to translate every Pattern that contains a sequence node by Algebraic+SequenceMatcher, where this very annoying special case can be added without major pain. That makes the 'Sequence' parts of the PatternMatcher class obsolete though... they will never be called. |