[MLton] Re: unexpected error message

Matthew Fluet fluet@cs.cornell.edu
Sat, 12 Nov 2005 16:44:14 -0500 (EST)

> The following erroneous file chatserver.mlb:
> chatserver.mlb
> yields
> dias@lakeland 448: mlton chatserver.mlb
> unhandled exception: Force

Indeed.  This is a consequence of interleaving lexing and parsing with 
elaboration through the use of promises.  The MLB lexer/parser front-end 
was responsible for detecting cycles and reporting errors, but now we 
forgoe forcing the AST of the MLB entry that would trigger the error 
message, because the elaborator already finds the MLB's denoted basis in 
the basis cache.  However, this element of the basis cache is the one we 
are currently evaluating, hence the exception.

I checked in a fix that forces the AST promise (which has the error 
message) when the Force exception is raised by forcing the denoted basis.
You'll now get an error like:

[fluet@localhost temp]$ mlton chatserver.mlb
Error: chatserver.mlb 1.1.
   Basis forms a cycle with chatserver.mlb.
     chatserver.mlb:1.1-1.15: chatserver.mlb
     <string>:1.1-1.17: chatserver.mlb
compilation aborted: parseAndElaborate reported errors