possible bug - with newlines?

1 view
Skip to first unread message

jon

unread,
Feb 21, 2008, 6:18:45 AM2/21/08
to Clojure
Hi Rich,
Using 20080213 release.. if I use Compiler.load from java to execute a
simple Test.clj file which has a last line containing a single form
not in parentheses (eg. 2 or :foo or ^bar) and *without a space or
carriage return* following it, I get:

Exception in thread "main" java.lang.Exception: Unable to resolve
symbol: \uffff in this context
at clojure.lang.Compiler.resolveIn(Compiler.java:3294)
at clojure.lang.Compiler.resolve(Compiler.java:3269)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:3254)
at clojure.lang.Compiler.analyze(Compiler.java:3117)
at clojure.lang.Compiler.analyze(Compiler.java:3104)
at clojure.lang.Compiler.eval(Compiler.java:3207)
at clojure.lang.Compiler.load(Compiler.java:3423)
at Main.gold2(Main.java:120)
at Main.main(Main.java:40)

John Cowan

unread,
Feb 21, 2008, 9:19:09 AM2/21/08
to clo...@googlegroups.com
On Thu, Feb 21, 2008 at 6:18 AM, jon <superu...@googlemail.com> wrote:

> Exception in thread "main" java.lang.Exception: Unable to resolve
> symbol: \uffff in this context

Ooops. Someone is failing to check for EOF before casting the value
returned by Reader#read into a Java char, producing that horrible and
dreadful dragon, the Spurious U+FFFF.

--
GMail doesn't have rotating .sigs, but you can see mine at
http://www.ccil.org/~cowan/signatures

Rich Hickey

unread,
Feb 21, 2008, 10:47:36 AM2/21/08
to Clojure


On Feb 21, 9:19 am, "John Cowan" <johnwco...@gmail.com> wrote:
> On Thu, Feb 21, 2008 at 6:18 AM, jon <superuser...@googlemail.com> wrote:
> > Exception in thread "main" java.lang.Exception: Unable to resolve
> > symbol: \uffff in this context
>
> Ooops. Someone is failing to check for EOF before casting the value
> returned by Reader#read into a Java char, producing that horrible and
> dreadful dragon, the Spurious U+FFFF.
>

That someone appears to be the java.io.PushbackReader, which does
exactly that in its unread(), yielding a nasty asymmetry between
read() and unread().

Aaargh - will work around.

Rich

Rich Hickey

unread,
Feb 21, 2008, 10:54:34 AM2/21/08
to Clojure


On Feb 21, 6:18 am, jon <superuser...@googlemail.com> wrote:
> Hi Rich,
> Using 20080213 release.. if I use Compiler.load from java to execute a
> simple Test.clj file which has a last line containing a single form
> not in parentheses (eg. 2 or :foo or ^bar) and *without a space or
> carriage return* following it, I get:
>
> Exception in thread "main" java.lang.Exception: Unable to resolve
> symbol: \uffff in this context

Fixed - thanks for the report,

Rich

John Cowan

unread,
Feb 21, 2008, 11:53:14 AM2/21/08
to clo...@googlegroups.com
On Thu, Feb 21, 2008 at 10:47 AM, Rich Hickey <richh...@gmail.com> wrote:

> That someone appears to be the java.io.PushbackReader, which does
> exactly that in its unread(), yielding a nasty asymmetry between
> read() and unread().

Right right right. I remember now having to work around exactly that
bug in TagSoup (a SAX parser written in Java to consume nasty, ugly
HTML and keep on truckin'; http://tagsoup.info) with a private
unread() method in my scanner, thus:


// Compensate for bug in PushbackReader that allows
// pushing back EOF.
private void unread(PushbackReader r, int c) throws IOException {
if (c != -1) r.unread(c);
}

That's all it takes, so I license you to use this snippet. :-)

Rich Hickey

unread,
Feb 21, 2008, 12:13:11 PM2/21/08
to Clojure


On Feb 21, 11:53 am, "John Cowan" <johnwco...@gmail.com> wrote:
> On Thu, Feb 21, 2008 at 10:47 AM, Rich Hickey <richhic...@gmail.com> wrote:
> > That someone appears to be the java.io.PushbackReader, which does
> > exactly that in its unread(), yielding a nasty asymmetry between
> > read() and unread().
>
> Right right right. I remember now having to work around exactly that
> bug in TagSoup (a SAX parser written in Java to consume nasty, ugly
> HTML and keep on truckin';http://tagsoup.info) with a private
> unread() method in my scanner, thus:
>
> // Compensate for bug in PushbackReader that allows
> // pushing back EOF.
> private void unread(PushbackReader r, int c) throws IOException {
> if (c != -1) r.unread(c);
> }
>
> That's all it takes, so I license you to use this snippet. :-)
>

I'd already re-invented exactly that, but thanks :)

Rich
Reply all
Reply to author
Forward
0 new messages