akeep / nanopass-framework-racket

Racket port of the nanopass-framework
MIT License
34 stars 9 forks source link

Improve error message for default nanopass-case message #35

Open soegaard opened 9 years ago

soegaard commented 9 years ago

When nanopass-case is called with a value V that no clauses match and there is no default else-clause the error message doesn't show the value V. The entire form is printed. Note that the DrRacket seems to color more than the nanopass-case expression red - which suggest that the source location is not correct.

Example of error message:

nanopass-case: empty else clause hit (nanopass-case (LFE2 GeneralTopLevelForm) T 
((unquote e) (Expr e id)) ((define-values (unquote s) ((unquote x) ...) (unquote e)) 
(quasiquote (define-values (unquote s) ((unquote x) ...) (unquote (RHS e id))))) 
((define-syntaxes (unquote s) ((unquote x) ...) (unquote e)) (quasiquote (define-syntaxes 
(unquote s) ((unquote x) ...) (unquote (RHS e id)))))) 
<pkgs>/nodejs/nodejs/compiler.rkt:804.6
soegaard commented 9 years ago

Also: It would be nice if unquote were printed as , in the error message.

akeep commented 9 years ago

Unfortunately, I don't think we have control over that:

-> (format "~s" '(a ,b ,c)) "(a (unquote b) (unquote c))"

unless there is a parameter to change how format works. Otherwise, we'd need to write our own format/pretty printer for s-expressions (which is doable but kind of a pain).

-andy:)

On July 19, 2015 at 9:44:15 AM, Jens Axel Søgaard (notifications@github.com) wrote:

Also: It would be nice if unquote were printed as , in the error message.

— Reply to this email directly or view it on GitHub.

soegaard commented 9 years ago

The ~v uses the current printer, which default to right thing:

> (format "~v" '(a ,b ,c))
"'(a ,b ,c)"

(error 'foo "the value is: ~v" '(if '1 '2 ,3))
foo: the value is: '(if '1 '2 ,3)
akeep commented 9 years ago

Cool... I was unaware of ~v I'll go through and use that places where we print s-expressions.

-andy:)

On July 19, 2015 at 10:48:57 AM, Jens Axel Søgaard (notifications@github.com) wrote: The ~v uses the current printer, which default to right thing:

(format "~v" '(a ,b ,c)) "'(a ,b ,c)"

(error 'foo "the value is: ~v" '(if '1 '2 ,3)) foo: the value is: '(if '1 '2 ,3)

— Reply to this email directly or view it on GitHub.