From 0f088022aac31f8ce9f174490c45f481db2faae9 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Thu, 28 Jan 2016 18:49:47 +0100 Subject: SI-9572 Check for illegal tuple sizes in the parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- test/files/neg/t9572.check | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 test/files/neg/t9572.check (limited to 'test/files/neg/t9572.check') diff --git a/test/files/neg/t9572.check b/test/files/neg/t9572.check new file mode 100644 index 0000000000..b95bd015cf --- /dev/null +++ b/test/files/neg/t9572.check @@ -0,0 +1,7 @@ +t9572.scala:3: error: too many elements for tuple: 23, allowed: 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) + ^ +t9572.scala:5: error: too many elements for tuple: 23, allowed: 22 + 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 + ^ +two errors found -- cgit v1.2.3