Carp/test-for-errors/no_matching_instance.carp

14 lines
439 B
Plaintext

;; This code should be rejected by the compiler.
(Project.config "file-path-print-length" "short")
(definterface some-interface (Fn [a] Bool))
;; A module implements it, accepting Int:s
(defmodule A (defn some-interface [x] (Int.= x 1)))
;; The function 'f' uses the interface, should still have a generic type though.
(defn f [x] (some-interface x))
;; Calling f with some type except Int shouldn't be possible.
(defn g [] (f 10.0f))