akeep / nanopass-framework-racket

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

Errors in (error ...) usage #25

Closed soegaard closed 9 years ago

soegaard commented 9 years ago

It seems that the Chez Scheme error procedure use a different convention than Racket.

Racket expects the following: (error src format-string v ...) If there are no ~a (or similar) in the format string then an error will throw an error if there are any additional arguments present.

Below is a list of places where I think there could be problems. The list is an edited version of the output of

grep -A3 "(error" *.rkt > errors.txt

run in nanopass-framework-racket/private/

helpers.rkt: (error who "invalid optimization level" n))

language-node-counter.rkt: [else (error '#,proc-name "unrecognized term" x)]))

language-node-counter.rkt: [else (error 'name "unrecognized language record" x)])))))))))])))

parser.rkt: [else (error who "expected to find matching tspec" alt)])])

parser.rkt: (error (if trace? 'trace-define-syntax 'define-syntax)

parser.rkt- "invalid language identifier" lang))

pass-helper.rkt: [else (error 'syntax->datum-helper "unexpected type" stx)])))]))

pass.rkt: [else (error who "unrecognized nano-rec" nrec)])))

pass.rkt: [(terminal-alt? in-altrec) (error who "unexpected terminal alt" in-altrec)]

pass.rkt: [(nonterminal-alt? in-altrec) (error who "unexpected nonterminal alt" in-altrec)])))

pass.rkt: (unless (list? ls) (error 'who "not a proper list" ls))

pass.rkt: (error 'who "mismatched list lengths" ls1 ls2 ...)))

pass.rkt: #`(error '#,(pass-desc-name pass-desc) pass.rkt- #,(format "unexpected ~s" (maybe-syntax->datum itype))

pass.rkt- #,fml))])))

pass.rkt: #`(error '#,(pass-desc-name pass-desc) pass.rkt- #,(format "unexpected ~s" (maybe-syntax->datum itype))

pass.rkt- #,fml))]))]))))))))))

records.rkt: [else (error who "unexpected alt" alt)])))

records.rkt: [else (error who "unrecognized type" x)])))

records.rkt: [else (error who "unrecognized type" x)])))

records.rkt: [else (error who "unexpected alt" ialt)]))))

unparser.rkt: [else (error who "invalid record" ir)]))))))

unparser.rkt: [else (error '#,name unparser.rkt- "unrecognized language record" unparser.rkt- ir)])])))))))

akeep commented 9 years ago

Yes, R6RS Scheme has an error with no format string, just a message string, so the arguments are reported as irritants.  Chez has an alternative errorf that looks more like Racket's error.

Thanks for the list, I'll take a look.

-andy:)

On July 9, 2015 at 12:53:54 PM, Jens Axel Søgaard (notifications@github.com) wrote:

It seems that the Chez Scheme error procedure use a different convention than Racket.

Racket expects the following: (error src format-string v ...) If there are no ~a (or similar) in the format string then an error will throw an error if there are any additional arguments present.

Below is a list of places where I think there could be problems. The list is an edited version of the output of

grep -A3 "(error" *.rkt > errors.txt

run in nanopass-framework-racket/private/

helpers.rkt: (error who "invalid optimization level" n))

language-node-counter.rkt: [else (error '#,proc-name "unrecognized term" x)]))

language-node-counter.rkt: [else (error 'name "unrecognized language record" x)])))))))))])))

parser.rkt: [else (error who "expected to find matching tspec" alt)])])

parser.rkt: (error (if trace? 'trace-define-syntax 'define-syntax)

parser.rkt- "invalid language identifier" lang))

pass-helper.rkt: [else (error 'syntax->datum-helper "unexpected type" stx)])))]))

pass.rkt: [else (error who "unrecognized nano-rec" nrec)])))

pass.rkt: [(terminal-alt? in-altrec) (error who "unexpected terminal alt" in-altrec)]

pass.rkt: [(nonterminal-alt? in-altrec) (error who "unexpected nonterminal alt" in-altrec)])))

pass.rkt: (unless (list? ls) (error 'who "not a proper list" ls))

pass.rkt: (error 'who "mismatched list lengths" ls1 ls2 ...)))

pass.rkt: #`(error '#,(pass-desc-name pass-desc) pass.rkt- #,(format "unexpected ~s" (maybe-syntax->datum itype))

pass.rkt- #,fml))])))

pass.rkt: #`(error '#,(pass-desc-name pass-desc) pass.rkt- #,(format "unexpected ~s" (maybe-syntax->datum itype))

pass.rkt- #,fml))]))]))))))))))

records.rkt: [else (error who "unexpected alt" alt)])))

records.rkt: [else (error who "unrecognized type" x)])))

records.rkt: [else (error who "unrecognized type" x)])))

records.rkt: [else (error who "unexpected alt" ialt)]))))

unparser.rkt: [else (error who "invalid record" ir)]))))))

unparser.rkt: [else (error '#,name unparser.rkt- "unrecognized language record" unparser.rkt- ir)])])))))))

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