Skip to content

Commit

Permalink
Add nullary function shorthand
Browse files Browse the repository at this point in the history
Fixes #70
  • Loading branch information
eliaslfox committed Sep 7, 2021
1 parent 56aabe6 commit 0a24eda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ast/parse-form.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ This does not attempt to do any sort of analysis whatsoever. It is suitable for
(parse-seq expr subnodes sr package))
;; Application
((t &rest rands)
(when (= 0 (length rands))
(error-parsing expr "Unable to call nullary function."))
(parse-application expr (first expr) rands sr package))))
(if (= 0 (length rands))
(parse-application expr (first expr) `(coalton-user::Unit) sr package)
(parse-application expr (first expr) rands sr package)))))
(t (error-parsing expr "The expression is not a valid value expression."))))

(defun invert-alist (alist)
Expand Down
4 changes: 4 additions & 0 deletions src/typechecker/derive-type.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Returns (VALUES type predicate-list typed-node subs)")
(rands (node-application-rands value))
(ret-ty (make-variable))
(typed-rands nil))

(when (= 0 (length rands))
(coalton-impl::coalton-bug "Invalid application with 0 arguments ~A." rator))

(multiple-value-bind (fun-ty fun-preds typed-rator substs)
(derive-expression-type rator env substs)
(unless (or (tvar-p fun-ty)
Expand Down

0 comments on commit 0a24eda

Please sign in to comment.