Skip to content

What's New in v1.15

"The Payloads Release" — two correctness fixes that remove long-standing sharp edges: any scalar can now ride inside an Option or Result, and your function names no longer collide with the C standard library.

It's all backward compatible — no source changes are required to upgrade.

Highlights

  • float? / bool? and Result<float, _> / Result<bool, _> now compile — previously only int and string payloads worked.
  • Function names can shadow libc symbolsconnect, read, write, socket, and friends are now free to use.

Float and Bool Optionals and Results

Before v1.15, only int and string payloads worked inside an Option or Result — a -> float? function wouldn't compile. Now every scalar works, in every position:

wyn
fn half(x: float) -> float? {
    if x < 0.0 { return None }
    return Some(x / 2.0)
}

fn divide(a: float, b: float) -> Result<float, string> {
    if b == 0.0 { return Err("division by zero") }
    return Ok(a / b)
}

You can match on them in both statement and expression position:

wyn
match half(9.0) {
    Some(v) => println("half is ${v}"),   // half is 4.5
    None => println("negative input"),
}

var result = divide(10.0, 4.0)
var msg = match result {
    Ok(v) => "quotient ${v}",
    Err(e) => "error: ${e}",
}
println(msg)                               // quotient 2.5

The method API works too — .is_some(), .unwrap(), and .unwrap_or(default):

wyn
var maybe = half(8.0)
if maybe.is_some() {
    println("got ${maybe.unwrap()}")       // got 4.0
}
println(half(-1.0).unwrap_or(0.0))         // 0.0

Booleans behave the same way:

wyn
fn parse_flag(s: string) -> bool? {
    if s == "on" { return Some(true) }
    if s == "off" { return Some(false) }
    return None
}

match parse_flag("on") {
    Some(v) => println("flag is ${v}"),     // flag is true
    None => println("unknown flag"),
}

Function Names Can Shadow libc Symbols

A function named connect, read, write, open, close, socket, send, listen, index, and many others used to fail to compile with a cryptic C error (static declaration of 'connect' follows non-static declaration). Those names are now free to use — the generated C is transparently namespaced, so your Wyn code is completely unaffected:

wyn
fn connect(host: string) -> string {
    return "connected to ${host}"
}

fn read(n: int) -> int {
    return n + 1
}

fn main() {
    println(connect("localhost"))          // connected to localhost
    println(read(41))                      // 42
}

Pick the name that reads best for your domain — the compiler handles the rest.

Upgrading

bash
wyn --version        # 1.15.0

No source changes are required — v1.15.0 is a drop-in upgrade over v1.14.0.

See also

MIT License — v1.16