Skip to content

Chapter 25: What's New in v1.11 ​

v1.11 is "The Developer Experience Release" - focused on making developers productive in their first hour.

New Language Features ​

enum.to_string() ​

Enums now have a .to_string() method that returns the variant name as a string:

wyn
enum Color { Red, Green, Blue }

println(Color.Red.to_string())   // "Red"

var c = Color.Blue
println(c.to_string())           // "Blue"

Previously, .to_string() on an enum returned the integer value ("0", "1", etc.), which was confusing and useless for debugging.

Indexed Iteration ​

You can now get both the index and value when iterating over an array:

wyn
var fruits = ["apple", "banana", "cherry"]
for i, v in fruits {
    println(i.to_string() + ": " + v)
}
// 0: apple
// 1: banana
// 2: cherry

This is similar to Python's enumerate() or Go's for i, v := range.

String Repeat Operator ​

Multiply a string by an integer to repeat it:

wyn
println("ha" * 3)    // "hahaha"
println("-" * 40)     // 40 dashes

Optional Type Syntax ​

int? is shorthand for OptionInt:

wyn
var x: int? = OptionInt_Some(42)
var y: int? = OptionInt_None()
println(OptionInt_unwrap(x).to_string())       // 42
println(OptionInt_unwrap_or(y, 0).to_string())  // 0

Compiler Improvements ​

Missing Return is an Error ​

Functions with a return type that don't return on all paths now fail to compile:

wyn
fn get() -> int {
    // v1.10: Warning (compiles, returns garbage)
    // v1.11: Error - won't compile
}

This catches a whole class of silent bugs.

Type Mismatch Errors ​

Type errors now come from Wyn with clear messages:

Error: Type mismatch at line 2
  Expected: int (integer)
  Got:      string (text string)
  Suggestion: use .to_int() to parse the string

Typed Arrays ​

var arr: [int] = [] uses a specialized representation with raw long long* storage - no type tags, no boxing. Building and summing a 1M-element int array takes ~11ms.

Tooling ​

  • wyn build now shows binary size and compile time: ✓ Built: myapp (51KB, 295ms)
  • wyn test works from any project directory (no longer requires being in the compiler directory)
  • wyn fmt --check exits non-zero if files need formatting (for CI)
  • wyn init now creates a .gitignore file
  • Missing packages show: Error: Package 'redis' not installed → Run: wyn pkg install redis
  • Unknown commands show: Error: Unknown command 'bild' → Did you mean wyn build?

Upgrading ​

No breaking changes except:

  1. Functions with missing returns that compiled with a warning will now fail. Add the missing return.
  2. enum.to_string() returns the variant name instead of the integer. If you need the integer, use int_to_string().

MIT License - v1.22.0