Better error messages for let, in certain cases
This commit is contained in:
parent
b853d49b31
commit
b050c4f192
|
@ -119,7 +119,15 @@
|
||||||
#:attr id #'x
|
#:attr id #'x
|
||||||
#:attr expr #'e
|
#:attr expr #'e
|
||||||
#:attr type (cond
|
#:attr type (cond
|
||||||
[(attribute t) #'t]
|
[(attribute t)
|
||||||
|
;; TODO: Code duplication in ::
|
||||||
|
(unless (type-check/syn? #'e #'t)
|
||||||
|
(raise-syntax-error
|
||||||
|
'let
|
||||||
|
(format "Term ~a does not have expected type ~a. Inferred type was ~a"
|
||||||
|
(cur->datum #'e) (cur->datum #'t) (cur->datum (type-infer/syn #'e)))
|
||||||
|
#'e (quasisyntax/loc #'x (x e))))
|
||||||
|
#'t]
|
||||||
[(type-infer/syn #'e)]
|
[(type-infer/syn #'e)]
|
||||||
[else
|
[else
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
|
@ -137,6 +145,7 @@
|
||||||
(syntax-case syn ()
|
(syntax-case syn ()
|
||||||
[(_ pf t)
|
[(_ pf t)
|
||||||
(begin
|
(begin
|
||||||
|
;; TODO: Code duplication in let-clause pattern
|
||||||
(unless (type-check/syn? #'pf #'t)
|
(unless (type-check/syn? #'pf #'t)
|
||||||
(raise-syntax-error
|
(raise-syntax-error
|
||||||
'::
|
'::
|
||||||
|
|
Loading…
Reference in New Issue
Block a user