flan/test/syntax/infer/main.fln

29 lines
590 B
Plaintext

;; Return types read off the body: no arrow here, _ in the return slot in
;; main.flan. Each shape the rule has: one type, a call's type, two types
;; (dyn), nothing (()), and a return that never falls off the end.
fn add(x: i32, y: i32) = x + y
fn half(x: f64) = x / 2.0
fn quarter(x: f64) = half(half(x))
fn pick(c: bool)
if c
return 1
2.5
fn say(x: i32) = println(x)
fn- floor0(x: i32)
if x < 0 then return 0 else x
fn main() -> i32
println(add(1, 2))
println(quarter(10.0))
println(pick(true))
println(pick(false))
say(4)
println(floor0(-3), floor0(5))
0