Make tests pass

This commit is contained in:
Isaac Shoebottom 2025-04-10 06:05:17 -03:00
parent b13264feed
commit 25758dc44a

View File

@ -127,9 +127,11 @@
(if (equal? var-t val-t) (if (equal? var-t val-t)
body-t body-t
(error 'typecheck "type does not match annotation")))] (error 'typecheck "type does not match annotation")))]
[(objE fields) (let* ([extract-exp (lambda (obj) (pair (fst obj) (typecheck (snd obj) env)))] [(objE fields)
(let*
([extract-exp (lambda (obj) (pair (fst obj) (typecheck (snd obj) env)))]
[field-list (map extract-exp fields)]) [field-list (map extract-exp fields)])
(objT (make-hash field-list)))] (objT (hash field-list)))]
[(msgE obj selector) [(msgE obj selector)
(type-case Exp obj (type-case Exp obj
[(objE fields) [(objE fields)
@ -141,7 +143,9 @@
[(objT fields) [(objT fields)
(type-case (Optionof Type) (hash-ref fields selector) (type-case (Optionof Type) (hash-ref fields selector)
[(none) (error 'typecheck "unknown field")] [(none) (error 'typecheck "unknown field")]
[(some v) v])] [(some v) (type-case Type v
[(arrowT arg-type result-type) v ]
[else v])])]
[else (error 'typecheck "bound variable is not an object")])] [else (error 'typecheck "bound variable is not an object")])]
[else (error 'typecheck "passing message to non-object")])]))) [else (error 'typecheck "passing message to non-object")])])))