Skip to content

SI-9572 Check for illegal tuple sizes in the parser#4927

Merged
retronym merged 1 commit intoscala:2.11.xfrom
szeiger:issue/9572
Feb 1, 2016
Merged

SI-9572 Check for illegal tuple sizes in the parser#4927
retronym merged 1 commit intoscala:2.11.xfrom
szeiger:issue/9572

Conversation

@szeiger
Copy link
Contributor

@szeiger szeiger commented Jan 28, 2016

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.

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.
@scala-jenkins scala-jenkins added this to the 2.11.8 milestone Jan 28, 2016
@retronym
Copy link
Member

LGTM

Small tip for next time to help lazy reviewers like me. For changes that necessitate moving chunks of existing code around, split it into two commits: one to move things around without changing behaviour, and another to make the actual change.

retronym added a commit that referenced this pull request Feb 1, 2016
SI-9572 Check for illegal tuple sizes in the parser
@retronym retronym merged commit cc6fea6 into scala:2.11.x Feb 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants