From 9d925a30c73ee5856c83d3caab124f7dbeaa85a8 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sun, 22 Apr 2012 02:58:26 -0700 Subject: SI-5702 Pattern parser halts on star In patterns, the parser halts when it sees stars. This means it does not handle infix notation for a case class named "*". This patch uses lookahead to decide whether to parse '_' '*' as a sequence pattern or as the start of infix. (For both normal and error cases, the tokens are always consumed immediately.) Error messages are improved for _* (as a help to learners) and slightly improved recovery helps the parse continue. The entry point for XML patterns is now distinct; otherwise, the change is local to pattern3-simplepattern; the entry point for simplepattern() is unchanged because it is commented "hook for IDE." --- test/files/neg/t1878.check | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'test/files/neg/t1878.check') diff --git a/test/files/neg/t1878.check b/test/files/neg/t1878.check index b47367e12c..ac2071c3d8 100644 --- a/test/files/neg/t1878.check +++ b/test/files/neg/t1878.check @@ -1,21 +1,7 @@ -t1878.scala:3: error: _* may only come last +t1878.scala:3: error: bad use of _* (a sequence pattern must be the last pattern) val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:3: error: scrutinee is incompatible with pattern type; - found : Seq[A] - required: String - val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:3: error: not found: value f - val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:3: error: value _2 is not a member of object Seq - val err1 = "" match { case Seq(f @ _*, ',') => f } - ^ -t1878.scala:9: error: _* may only come last + ^ +t1878.scala:9: error: bad use of _* (a sequence pattern must be the last pattern) val List(List(_*, arg2), _) = List(List(1,2,3), List(4,5,6)) - ^ -t1878.scala:13: error: _* may only come last - case

{ _* }

=> - ^ -6 errors found + ^ +two errors found -- cgit v1.2.3