diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-07 13:55:12 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-07 13:55:12 -0700 |
commit | 5c77e01794434b2fa01a1bd250c08198c31796e3 (patch) | |
tree | 1669ee08d4d40f2324bfda821f66967b57496d32 /src | |
parent | 0f74eda2431ca2b9ae3b48ffdd6f7e5502a0843c (diff) | |
parent | d0a1f5b1c4d97f3e0368dc89691097a1b836a116 (diff) | |
download | scala-5c77e01794434b2fa01a1bd250c08198c31796e3.tar.gz scala-5c77e01794434b2fa01a1bd250c08198c31796e3.tar.bz2 scala-5c77e01794434b2fa01a1bd250c08198c31796e3.zip |
Merge pull request #2472 from paulp/pr/2.10.2/7385
SI-7385 crash in erroneous code
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 6f79f639b9..b05902a6ef 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1332,11 +1332,10 @@ self => def parseWhile = { val start = in.offset atPos(in.skipToken()) { - val lname: Name = freshTermName(nme.WHILE_PREFIX) val cond = condExpr() newLinesOpt() val body = expr() - makeWhile(lname, cond, body) + makeWhile(start, cond, body) } } parseWhile diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index cd93221c50..b5771454f8 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -251,8 +251,13 @@ abstract class TreeBuilder { else CompoundTypeTree(Template(tps, emptyValDef, Nil)) /** Create tree representing a while loop */ - def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = { - val continu = atPos(o2p(body.pos pointOrElse wrappingPos(List(cond, body)).pos.endOrPoint)) { Apply(Ident(lname), Nil) } + def makeWhile(startPos: Int, cond: Tree, body: Tree): Tree = { + val lname = freshTermName(nme.WHILE_PREFIX) + def default = wrappingPos(List(cond, body)) match { + case p if p.isDefined => p.endOrPoint + case _ => startPos + } + val continu = atPos(o2p(body.pos pointOrElse default)) { Apply(Ident(lname), Nil) } val rhs = If(cond, Block(List(body), continu), Literal(Constant())) LabelDef(lname, Nil, rhs) } |