~jojo/Carth

fb4e8f9bd7a18efa9c150e965576926d88755aa7 — JoJo 1 year, 9 months ago ba3f587
Update error-examples for "newly" added type errors

Some were added a while ago, I've just not paid err.carth enough
attention.
1 files changed, 76 insertions(+), 3 deletions(-)

M examples/err.carth
M examples/err.carth => examples/err.carth +76 -3
@@ 1,5 1,7 @@
;; Main not defined
(define (main _) (printInt 1))
(import std)

;; Start not defined
(define (start _) (undefined unit))

;; Invalid user type signature
;; (define: (invalid-user-type-signature x)


@@ 26,7 28,78 @@
;; (define infinite-type (Wrap infinite-type))

;; Type mismatch
(define type-mismatch (Integ "foo"))
;; (define type-mismatch (Integ "foo"))

;; Conflicting definitions for type
;; (type Foo)
;; (type Foo)

;; Conflicting definitions for constructor
;; a)
;; (type Foo Bar Bar)
;; b)
;; (type Baz Baz)
;; (type Quux Baz)

;; Redundant case in pattern match
;; (define foo
;;   (fun-match
;;     (case true 0)
;;     (case true 1)
;;     (case false 2)))

;; Inexhaustive patterns
;; (define foo
;;   (fun-match
;;     (case true 0)))

;; Extern is not monomorphic
;; (extern foo (Fun a Int))

;; Found hole
;; (define foo
;;   _)

;; Type has infinite size due to recursion
;; (type Foo (Foo Foo))

;; Undefined type
;; a)
;; (type Foo (Foo Bar))
;; b)
;; TODO: This one compiles
;; (define: foo
;;     (Fun Int Foo)
;;   (undefined unit))

;; Could not fully infer type of expression. Unbound type variable.
;; (define foo
;;   (seq (undefined unit)
;;        123))

;; Incorrect type of start
;; (define: start
;;     Int
;;   (undefined unit))

;; Non-function variable definition is recursive
;; (define: foo
;;     Int
;;   (+ foo 1))

;; Arity mismatch for instantiation of type
;; a)
;; (type Foo (Foo List))
;; b)
;; TODO: This is not an error, but should be
;; (define: foo
;;     (Fun Int List)
;;   (undefined unit))

;; Duplicate definition
;; TODO: This is not an error, but should be
;; (define foo +)
;; (define foo -)

;; Helpers
(type (Wrap a) (Wrap a))