This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Apparent XML-related scalac/ant bug (2.8) - any workarounds?

3 replies
Danny Ayers
Joined: 2009-12-11,
User offline. Last seen 42 years 45 weeks ago.

trace below, started happening while I was tweaking some XML. Couldn't
find a related report/google mention, sorry if I've missed something
obvious.

I'm getting the same thing whether I run ant from within Eclipse
(3.5.2, using their updates) or at the command line. I believe I've
got the latest stable 2.8.0 stuff installed on Ubuntu 10.04,
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.1) (6b18-1.8.1-0ubuntu1)
OpenJDK Server VM (build 16.0-b13, mixed mode)

any suggestions?

Cheers,
Danny.

[scalac] java.lang.UnsupportedOperationException: Position.point
[scalac] at scala.tools.nsc.util.Position$class.point(Position.scala:88)
[scalac] at scala.tools.nsc.util.NoPosition$.point(Position.scala:193)
[scalac] at
scala.tools.nsc.util.Position$class.startOrPoint(Position.scala:85)
[scalac] at
scala.tools.nsc.util.NoPosition$.startOrPoint(Position.scala:193)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.simpleExprRest(Parsers.scala:1332)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.simpleExpr(Parsers.scala:1311)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.prefixExpr(Parsers.scala:1256)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.postfixExpr(Parsers.scala:1208)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.expr0(Parsers.scala:1129)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.expr(Parsers.scala:1052)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.expr(Parsers.scala:1047)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.patDefOrDcl(Parsers.scala:2118)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.defOrDcl(Parsers.scala:2078)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.localDef(Parsers.scala:2655)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$blockStatSeq$1.apply(Parsers.scala:2682)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$blockStatSeq$1.apply(Parsers.scala:2668)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:257)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.blockStatSeq(Parsers.scala:2668)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.block(Parsers.scala:1387)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.blockExpr(Parsers.scala:1377)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.simpleExpr(Parsers.scala:1298)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.prefixExpr(Parsers.scala:1256)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.postfixExpr(Parsers.scala:1208)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.expr0(Parsers.scala:1129)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.expr(Parsers.scala:1052)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.expr(Parsers.scala:1047)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.equalsExpr(Parsers.scala:1006)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.funDefOrDcl(Parsers.scala:2221)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.defOrDcl(Parsers.scala:2080)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.nonLocalDefOrDcl(Parsers.scala:2092)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1$$anonfun$apply$3.apply(Parsers.scala:2606)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1$$anonfun$apply$3.apply(Parsers.scala:2606)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.joinComment(Parsers.scala:499)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1.apply(Parsers.scala:2606)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1.apply(Parsers.scala:2575)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:257)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.templateStatSeq(Parsers.scala:2575)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.templateBody(Parsers.scala:2461)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.templateBodyOpt(Parsers.scala:2468)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.templateOpt(Parsers.scala:2439)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.objectDef(Parsers.scala:2365)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.tmplDef(Parsers.scala:2307)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.topLevelTmplDef(Parsers.scala:2290)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStatSeq$2.apply(Parsers.scala:2557)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStatSeq$2.apply(Parsers.scala:2557)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.joinComment(Parsers.scala:499)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.topStatSeq(Parsers.scala:2557)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.topstats$1(Parsers.scala:2727)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.topstats$1(Parsers.scala:2718)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:2731)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:2697)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:257)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.compilationUnit(Parsers.scala:2697)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$UnitParser$$anonfun$parseStartRule$1.apply(Parsers.scala:70)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$UnitParser$$anonfun$parseStartRule$1.apply(Parsers.scala:70)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$Parser.parse(Parsers.scala:184)
[scalac] at
scala.tools.nsc.ast.parser.Parsers$UnitParser.smartParse(Parsers.scala:109)
[scalac] at
scala.tools.nsc.ast.parser.SyntaxAnalyzer$ParserPhase.apply(SyntaxAnalyzer.scala:27)
[scalac] at
scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply(Global.scala:276)
[scalac] at
scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply(Global.scala:276)
[scalac] at scala.tools.nsc.reporters.Reporter.withSource(Reporter.scala:48)
[scalac] at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:276)
[scalac] at
scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:252)
[scalac] at
scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:252)
[scalac] at scala.collection.Iterator$class.foreach(Iterator.scala:631)
[scalac] at
scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:304)
[scalac] at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:252)
[scalac] at scala.tools.nsc.Global$Run.compileSources(Global.scala:733)
[scalac] at scala.tools.nsc.Global$Run.compile(Global.scala:813)
[scalac] at scala.tools.ant.Scalac.executeInternal(Scalac.scala:638)
[scalac] at scala.tools.ant.Scalac.execute(Scalac.scala:586)
[scalac] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[scalac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[scalac] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[scalac] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[scalac] at java.lang.reflect.Method.invoke(Method.java:616)
[scalac] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[scalac] at org.apache.tools.ant.Task.perform(Task.java:348)
[scalac] at org.apache.tools.ant.Target.execute(Target.java:357)
[scalac] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[scalac] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
[scalac] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[scalac] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[scalac] at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[scalac] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
[scalac] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[scalac] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Apparent XML-related scalac/ant bug (2.8) - any workarounds

Hi Danny,
> trace below, started happening while I was tweaking some XML. Couldn't
> find a related report/google mention, sorry if I've missed something
> obvious.
>
> I'm getting the same thing whether I run ant from within Eclipse
> (3.5.2, using their updates) or at the command line. I believe I've
> got the latest stable 2.8.0 stuff installed on Ubuntu 10.04,
> java version "1.6.0_18"
> OpenJDK Runtime Environment (IcedTea6 1.8.1) (6b18-1.8.1-0ubuntu1)
> OpenJDK Server VM (build 16.0-b13, mixed mode)
>
> any suggestions?

That's a scalac bug, but AST position errors of that kind normally
only manifest themselves in tools which use it in interactive mode
(ie. the Eclipse tooling for Scala) so I'm quite surprised that you
can reproduce this using Ant.

The code that reproduces this would help, particularly if you're able
to reduce it to a minimum. The bug is in the parser (ie. syntactic
rather than semantic), so (un-)commenting line by line should be
viable as a way of isolating the construct which is causing the
problem.

Cheers,

Miles

Danny Ayers
Joined: 2009-12-11,
User offline. Last seen 42 years 45 weeks ago.
Re: Apparent XML-related scalac/ant bug (2.8) - any workarounds

Hi Miles,

Thanks for the prompt response. I suspected I'd introduced a bug to my
code which was triggering the compiler bug, but wasn't 100% sure -
narrowing this down means I now have a workaround :)

I've attached the source, ant and trace files (running ant from a
command line), but essentially this is causing the Position.point
compiler error:

{"text"}

note the unclosed

I /think/ I've got that to a minimum, cutting it back further produces
the detailed parsing error reports you'd expect.

The command-line interpreter behaves as expected [oops! - version
2.7.7final does at least, I must have forgotten to change a simlink to
2.8 somewhere...so I may well have similar inconsistencies around my
build path]

Welcome to Scala version 2.7.7final (OpenJDK Server VM, Java 1.6.0_18).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import scala.xml._
import scala.xml._

scala> {"text"}
:1: error: in XML literal: expected closing tag of a
{"text"}
^
:1: error: start tag was here: a>
{"text"}

When trying scalac on the source directly at the command line I'm getting:
java.lang.NoClassDefFoundError: scala/tools/nsc/Main

- guess I'd better RTFM on that one :)

Cheers,
Danny.

On 17 August 2010 11:39, Miles Sabin wrote:
> Hi Danny,
>> trace below, started happening while I was tweaking some XML. Couldn't
>> find a related report/google mention, sorry if I've missed something
>> obvious.
>>
>> I'm getting the same thing whether I run ant from within Eclipse
>> (3.5.2, using their updates) or at the command line. I believe I've
>> got the latest stable 2.8.0 stuff installed on Ubuntu 10.04,
>> java version "1.6.0_18"
>> OpenJDK Runtime Environment (IcedTea6 1.8.1) (6b18-1.8.1-0ubuntu1)
>> OpenJDK Server VM (build 16.0-b13, mixed mode)
>>
>> any suggestions?
>
> That's a scalac bug, but AST position errors of that kind normally
> only manifest themselves in tools which use it in interactive mode
> (ie. the Eclipse tooling for Scala) so I'm quite surprised that you
> can reproduce this using Ant.
>
> The code that reproduces this would help, particularly if you're able
> to reduce it to a minimum. The bug is in the parser (ie. syntactic
> rather than semantic), so (un-)commenting line by line should be
> viable as a way of isolating the construct which is causing the
> problem.
>
> Cheers,
>
>
> Miles
>
> --
> Miles Sabin
> tel: +44 7813 944 528
> gtalk: miles@milessabin.com
> skype: milessabin
> http://www.chuusai.com/
> http://twitter.com/milessabin
>

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Apparent XML-related scalac/ant bug (2.8) - any workarounds

On Tue, Aug 17, 2010 at 2:38 PM, Danny Ayers wrote:
> Thanks for the prompt response. I suspected I'd introduced a bug to my
> code which was triggering the compiler bug, but wasn't 100% sure -
> narrowing this down means I now have a workaround :)
>
> I've attached the source, ant and trace files (running ant from a
> command line), but essentially this is causing the Position.point
> compiler error:
>
> {"text"}
>
> note the unclosed

Excellent stuff. I can reproduce the problem with scalac and in the REPL.

Ticket is here,

http://lampsvn.epfl.ch/trac/scala/ticket/3769

Cheers,

Miles

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland