;;;; An arm is checked at the other arm's type first: arithmetic in a ;;;; narrower arm is done at the wider type, not done narrow and widened, and ;;;; nil beside an Option is None, whichever arm comes first. (defn wd [c bool a i64 b i32] i64 (let [v (if c a (+ b 1))] v)) (defn wd2 [c bool a i64 b i32] i64 (if c a (+ b 1))) (defn wd4 [c bool a i64 b i32] i64 (let [v (if c a (* b b))] v)) (defn wd5 [o (Option i32) a i64 b i32] i64 (let [v (match o (Some q) a None (+ b 1))] v)) (defn wd6 [c bool a f64 b i32] f64 (let [v (if c a (/ b 2))] v)) (defn wd7 [c bool a i64 b i32] _ (when c (return a)) (+ b 1)) (defn n1 [c bool p (Option i64)] i64 (let [v (if c nil p)] (match v (Some q) q None -1))) (defn n2 [o (Option i32) p (Option i64)] i64 (let [v (match o None nil (Some z) p)] (match v (Some q) q None -1))) (defn main [] i32 (println (wd false 0 2147483647)) (println (wd2 false 0 2147483647)) (println (wd4 false 0 100000)) (println (wd5 None 0 2147483647)) (println (wd6 false 0.0 3)) (println (wd7 false 0 2147483647)) (println (n1 false (Some 5)) (n1 true (Some 5))) (println (n2 (Some 1) (Some 5)) (n2 None (Some 5))) 0)