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:
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:
var fruits = ["apple", "banana", "cherry"]
for i, v in fruits {
println(i.to_string() + ": " + v)
}
// 0: apple
// 1: banana
// 2: cherryThis 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:
println("ha" * 3) // "hahaha"
println("-" * 40) // 40 dashesOptional Type Syntax
int? is shorthand for OptionInt:
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()) // 0Compiler Improvements
Missing Return is an Error
Functions with a return type that don't return on all paths now fail to compile:
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 stringTyped Arrays
var arr: [int] = [] uses a specialized representation with raw long long* storage - no type tags, no boxing. Sum of 1M ints is 2x faster.
Tooling
wyn buildnow shows binary size and compile time:✓ Built: myapp (49KB, 362ms)wyn testworks from any project directory (no longer requires being in the compiler directory)wyn fmt --checkexits non-zero if files need formatting (for CI)wyn initnow creates a.gitignorefile- 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:
- Functions with missing returns that compiled with a warning will now fail. Add the missing
return. enum.to_string()returns the variant name instead of the integer. If you need the integer, useint_to_string().