dyoo / whalesong

Whalesong: Racket to JavaScript compiler
http://hashcollision.org/whalesong
250 stars 30 forks source link

Whalesong fails badly when given a program in an unexpected language #53

Closed dyoo closed 12 years ago

dyoo commented 12 years ago

From sk:


I was running the same file I sent you without changing the #lang line. So I thought maybe that's the problem, so I changed it to

#lang whalesong

but that just produced more errors -- I had to read very carefully to find that it didn't know what #lang whalesong is.


Originally, the line he had was

#lang planet dyoo/moby

which caused even worse problems, since the moby reader doesn't work under Racket 5.1.3 anymore.

Our driver, whalesong.rkt, must do a quick check on the lang line to make sure it either refers to #%kernel, or a language module of Whalesong. Anything else should immediately exit, even before reading, because we'll get horrible Racket errors otherwise.

dyoo commented 12 years ago

Should be addressed now in 0eab74e2e0dfcb20936a42af63638121d11a4ceb. I added a module check-valid-module-source that does several checks to catch these kinds of errors early and report in user-friendly manner.

If you try to compile a program written in #lang racket/base, Whalesong gives the following error message:

ERROR: The file #<path:/gpfs/main/home/dyoo/work/whalesong/foo.rkt> is a Racket module, but is written in the language racket/base [#<path:/gpfs/main/sys/shared/psfu/local/projects/racket/releases/5.1.3/collects/racket/base.rkt>], which Whalesong does not know how to compile.
Aborting compilation.

which should be better than what it was doing earlier.