# Xo 0.50 release notes


**Downloads:** [Xo 0.50.1 on GitHub](https://github.com/xo-lang/xo/releases/tag/v0.50.1),
with archives for macOS (Apple silicon and Intel, signed and
notarized), Linux (arm64 and x86-64), and Windows (x86-64, Authenticode
signed), and a `SHA256SUMS` file.

Xo 0.50.1, the first public 0.50 release (0.50.0 was an internal seed), fixes two security issues (a JSON request that could crash a server using `json.decode_go`, and TLS peer keys over 8192 bits), fixes two crashes (a native arm64 program whose large struct result was overwritten before it was read, and a rare one of programs whose tasks are canceled), adds RSA encryption, reads and writes times of any year from 0001 to 9999 (`time.Civil` with `parse_civil` and `format`, and in std/yaml, std/mail and std/asn1), lets an interface method take `var self`, writes protobuf messages up to about a third faster, and fixes faults in LLVM builds on linux/amd64. The playground's REPL now needs at most 37 MB of memory.

Upgrade advice: if you build native programs on arm64 (Apple silicon, Graviton) with 0.49.0 or 0.49.1, upgrade; a call returning a large struct could crash them (see Fixes).

Two changes can stop a program that compiled with 0.49.1 from compiling: std/asn1 gains a `Value.WideTime` variant, so an exhaustive `match` on `asn1.Value` needs that arm, and a `var` method no longer implements an interface method that takes a plain `self` (see Breaking changes).

## Security

- **std/tls** (native backends): a TLS peer certificate with an RSA key over 8192 bits is refused, with Go's text (`tls: server sent certificate containing RSA key larger than 8192 bits`), before any signature is verified. Huge keys made the peer's handshake cost CPU time (Go's CVE-2023-29409, GO-2023-1987). The Go backend already refused them.
- **std/json** (native and LLVM backends): `json.decode_go` no longer faults when a type error sits under a non-ASCII object key (`{"é": "x"}` decoded into `Map[Str, Int]`); it returns Go's error, `json: cannot unmarshal string into Go value of type int`. One such request could stop a server that decodes peer JSON with `decode_go`. Found by the decision 0616 review of std/json.

## Highlights

- **RSA encryption** (std/crypto, decision 0618): `crypto.encrypt_oaep` and `crypto.decrypt_oaep` (RSA-OAEP, Go's `EncryptOAEP` and `DecryptOAEP`) are the recommended scheme; `encrypt_pkcs1v15` and `decrypt_pkcs1v15` are legacy, for systems that require them. Decryption checks padding in constant time and reports every failure as the one `crypto/rsa: decryption error`.
- **Times of any year** (decision 0614): `time.parse_civil` and `Layout.parse_civil` read what `parse` reads, for years 0001 to 9999 (Go's zero Time, `9999-12-31`, BigQuery TIMESTAMP), into a `time.Civil`; `Civil.format`, `Layout.format_civil`, `Civil.unix` and `Civil.to_time` write and compare them. `Time` keeps its 1677 to 2262 range. A `time.Civil` field in std/yaml reads and writes any year (four digit years, as yaml.v3), `mail.parse_date_civil` reads RFC 5322 dates of any year, and std/asn1 parses UTCTime and GeneralizedTime of any year (see Breaking changes).
- **`var self` in interfaces** (decision 0613): an interface method may take `var self`, and a generic bound's call of one (`fn fill[T: Loader](var t: T) { t.load(5) }`) updates its receiver on every backend (native, LLVM, Go). Through an interface value (`var l: Loader = Box{}; l.load(3)`) it works on the Go backend, updating the value in its place (a copy made before the call keeps the old value); the native backends still report XO1201 for it.
- **Faster protobuf** (std/protobuf, std/prelude): varints and fixed width values are written as one word, derive Proto writes each field's key with its value (new `put_key_varint`, `put_key_fixed32`, `put_key_bytes`), and `BytesBuilder.write_le`, `write_byte` and `StrBuilder` pushes store in place. Each step's `xo bench --ab` on linux/arm64 against the main before it: bench/perf/protobuf marshal 0.856 (varint words), 0.847 (keys with values), 0.827 (`write_le`); the JSON token writer 0.918 (`write_byte`). Output bytes are unchanged.
- **The playground's REPL** ([xolang.dev/repl/](/repl/), decision 0583): its compiler peaks at 37 MB over a 30-entry session, was 49 in 0.49.1, and later entries run a little faster.

## Breaking changes

- **std/asn1** (decision 0614): a UTCTime or GeneralizedTime outside 1678 to 2261 parses as the new `Value.WideTime(c: time.Civil, generalized: Bool)` (its wall clock and offset), where it was `asn1: time out of range`; `der` writes it back in UTC, as Go's Marshal. Migration: add a `Value.WideTime(c, g)` arm to exhaustive matches on `asn1.Value`.
- **Interfaces** (decision 0613): a type's `var` method no longer implements an interface method that takes a plain `self` (new error XO0439). The checker used to accept it, but a call through the interface would have lost the update, and every native build reported XO1201. Migration: if callers through the interface may change the value, declare the interface method `fn name(var self, ...)` and give generic callers a `var` receiver (`fn fill[T: Loader](var t: T)`); if the method only reads, make it a plain method `fn (x: T) name(...)`.

## Behavior changes

- **wasm, `BytesBuilder.write_le`:** a width outside 0 to 8 is the fault the native backends raise (exit 70, the same text), where it trapped ("unreachable", exit 134).

## Not in this release

- **Borrowed struct projections** (decision 0612), listed in the changelog, are off in 0.50.1: a native build of the Azure SDK's pagers crashed (SIGSEGV) with them on. They return when that is fixed.

## Fixes

- **arm64 native builds:** a call returning a large struct (a result wider than the return registers) could have its result overwritten by a value's cleanup call before the caller read it, a segmentation fault (since 0.49.0; 0.48.2 and earlier are not affected). Found through a native build of the Azure SDK's pagers.
- **Canceled tasks** (native backends and LLVM): a task canceled while it waited for another task to build a constant (a sibling failed while the constant's first read was in progress) now unwinds; it read past an empty list, and the program crashed with SIGSEGV about 1 run in 30 under load. Present since at least 0.48.2.
- **`--backend=llvm` on linux/amd64 and freebsd/amd64:** a fault (an overflow, a failed contract, an unhandled error) crashed the program with SIGSEGV instead of reporting the fault and exiting 70. And `xo dump` (and SIGQUIT) of an LLVM build named the runtime's frame (`poll.xo:1187`) as a blocked task's site instead of the program's line.
- **Closures** (native backends): a closure with no written result whose body ends in an `if` or a `match` (`fn(d: Int) { if d > 0 { d } else { 0 } }`) builds; it was XO1201 "converting `Result[Int, _]` to `Int`" (the Go backend ran it).
- **Diagnostics:** an XO1201 found while lowering a closure body names the place (the returned expression, else the closure literal or the function); it had no file or line.
- **Checker:** a type alias reached again through a struct or enum (`type Schema = List[Field]` with `struct Field { schema: Schema }`) is no longer a false XO0407 "type alias refers to itself".
- **std/yaml:** a `time.Civil` field outside 1677 to 2262 failed to parse, and a year below 1000 was written without its leading zeros (`1-01-01T00:00:00Z`).

