Better error messages for TR lambda parsing
original commit: ad4f6e1ea1f9c0e2e7ca30e6ea6d8c6e8a50f0ca
This commit is contained in:
parent
f1fbe180e2
commit
ca0c7f3f35
|
@ -1183,21 +1183,28 @@ This file defines two sorts of primitives. All of them are provided into any mod
|
|||
#:attr opt-property
|
||||
(list (length (attribute mand)) (length (attribute opt)))
|
||||
#:attr erased
|
||||
(template ((?@ . mand.form) ... (?@ . opt.form) ... . rest.form)))))
|
||||
(template ((?@ . mand.form) ... (?@ . opt.form) ... . rest.form))))
|
||||
|
||||
(define-splicing-syntax-class return-ann
|
||||
#:description "return type annotation"
|
||||
#:literals (:)
|
||||
(pattern (~seq : type:expr))
|
||||
(pattern (~seq) #:attr type #f)))
|
||||
|
||||
|
||||
;; annotation to help tc-expr pick out keyword functions
|
||||
(define-syntax (-lambda stx)
|
||||
(syntax-parse stx
|
||||
#:literals (:)
|
||||
[(_ formals:lambda-formals (~optional (~seq : return-type:expr))
|
||||
e ... last-e)
|
||||
[(_ formals:lambda-formals return:return-ann
|
||||
(~describe "body expression or definition" e) ...
|
||||
(~describe "body expression" last-e))
|
||||
;; Annotate the last expression with the return type. Should be correct
|
||||
;; since if a function returns, it has to do so through the last expression
|
||||
;; even with continuations.
|
||||
(define/with-syntax last-e*
|
||||
(if (attribute return-type)
|
||||
#`(ann last-e #,(attribute return-type))
|
||||
(if (attribute return.type)
|
||||
#`(ann last-e #,(attribute return.type))
|
||||
#'last-e))
|
||||
(define d (syntax/loc stx (λ formals.erased e ... last-e*)))
|
||||
(if (attribute formals.kw-property)
|
||||
|
|
Loading…
Reference in New Issue
Block a user