minor problem and workaround with for

Per Bothner per@bothner.com
Fri Dec 20 10:36:00 GMT 2002


Anthony Tomasic wrote:
> {--1--} for $x in (1 to 3) return ($x,$x)
> 1 1 2 2 3 3
> {--2--} for $x in (1 to 3) return $x, $x
> <stdin>:2:1: internal error while compiling - caught: 
> java.lang.NullPointerException

Actually, according to the spec:
     for $x in (1 to 3) return $x, $x
is supposed to parse as:
     (for $x in (1 to 3) return $x), $x
which of course has an unbound variable reference.

The attached fixes the compiler failure.  We now get:

{--1--} let $y := 10 return (for $x in (1 to 3) return $x, $y)
1 2 3 10
{--2--} for $x in (1 to 3) return $x, $x
gnu.mapping.UnboundSymbol: Unbound symbol x
	at gnu.mapping.Constraint.get(Constraint.java:15)
	at gnu.mapping.Binding.get(Binding.java:25)
	at atInteractiveLevel.apply(Unknown Source)
	at gnu.mapping.CallContext.runUntilDone(CallContext.java:239)
	at gnu.expr.ModuleExp.evalModule(ModuleExp.java:189)
	at kawa.Shell.run(Shell.java:231)
	at kawa.Shell.run(Shell.java:180)
	at kawa.Shell.run(Shell.java:167)
	at kawa.Shell.run(Shell.java:154)
	at kawa.repl.main(repl.java:600)
  1 2 3

It would be nice to improve this so we get line- and column-numbers
in the exception message, but that is a fix for another day.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: XQParser.patch
URL: <http://sourceware.org/pipermail/kawa/attachments/20021220/8408751f/attachment.ksh>


More information about the Kawa mailing list