flan/test/programs/optionals-trap.fln

18 lines
398 B
Plaintext

;; x! over nothing traps at its own site and names the expression: 1 is a
;; typed Option that is None, 2 a dyn that is nil.
struct Cfg
port: i32?
fn nothing(x) = x
fn main(args: [str]) -> i32
let k = if length(args) > 1 then bytes->i64(bytes-view(args[1])) else 0
println("before")
let cfg = Cfg{.port None}
if k == 1
println(cfg.port!)
if k == 2
println(nothing(nil)!)
0