flan/test/programs/dev-infer.flan

21 lines
646 B
Plaintext

;;;; Return types read off the body, for the stale-caller warning's cause.
;;;; [speed]'s type is inferred and the tests change its body so that it
;;;; returns something else. [run] is a written caller, [relay] an inferred
;;;; one that returns what [speed] returns, and [sum] an inferred one whose
;;;; body stops checking once [speed] returns an f64: [twice] takes an i32.
(defn speed [x i32] _
(* x 2))
(defn run [] i32 (speed 3))
(defn relay [x i32] _ (speed x))
(defn twice [x i32] i32 (* x 2))
(defn sum [x i32] _ (twice (speed x)) (speed x))
(defn use-relay [] i32 (+ (relay 1) (sum 1)))
(defn main [] i32 (+ (run) (use-relay)))