summaryrefslogtreecommitdiff
path: root/test/files/neg/t9572.scala
diff options
context:
space:
mode:
authorStefan Zeiger <szeiger@novocode.com>2016-01-28 18:49:47 +0100
committerStefan Zeiger <szeiger@novocode.com>2016-01-28 18:49:47 +0100
commit0f088022aac31f8ce9f174490c45f481db2faae9 (patch)
tree8a063401cae28df22493aeda717b80d84cb48ad2 /test/files/neg/t9572.scala
parentea154faf467ae27c221ba0dcd7235e1e55673c51 (diff)
downloadscala-0f088022aac31f8ce9f174490c45f481db2faae9.tar.gz
scala-0f088022aac31f8ce9f174490c45f481db2faae9.tar.bz2
scala-0f088022aac31f8ce9f174490c45f481db2faae9.zip
SI-9572 Check for illegal tuple sizes in the parser
This commit adds explicit checks with syntax errors for tuple literals and types of more than 22 elements. An alternative approach to fixing SI-9572 would be to revert to the old failure mode of Scala 2.10 where references to arbitrary `scala.TupleXY` would be generated in the parser, which then leads to “type/object not found” errors in the typechecker. This fix here is more intrusive but arguably provides a better user experience. Methods `stripParens` and `makeBinop` are moved from `TreeBuilder` to `Parsers` because they can now generate syntax errors. New methods `makeSafeTupleType` and `makeSafeTupleTerm` implement the error checking on top of `makeTupleType` and `makeTupleTerm`. They are overridden with no-op versions in the quasiquotes parser because it also overrides `makeTupleType` and `makeTupleTerm` in a way that supports arbitrary tuple sizes.
Diffstat (limited to 'test/files/neg/t9572.scala')
-rw-r--r--test/files/neg/t9572.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/files/neg/t9572.scala b/test/files/neg/t9572.scala
new file mode 100644
index 0000000000..32b2db320e
--- /dev/null
+++ b/test/files/neg/t9572.scala
@@ -0,0 +1,6 @@
+class T9572 {
+ val term22 = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22)
+ val term23 = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23)
+ val type22: (Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) = null
+ val type23: (Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) = null
+}