Koja 0.19.0

Released September 22, 2026 · All releases · GitHub release

Added

  • The test "description" ... end declaration. A test block goes at the top level of a file or inside a struct, enum, impl, extend, or builtin body, so tests can sit next to the code they cover in src/. Blocks compile only under koja test and are dropped from every other command. Existing @test functions keep working alongside them.
  • The assert keyword, for test bodies. assert a == b fails the test with the source text, file, line, and both operands rendered through Debug. assert cond, "message" adds a message. Any other condition records its source text.
  • The Test package. Test.Failure is the one error type a test body can fail with. Test.require unwraps a setup step that must succeed, Test.skip ends a test as skipped with a reason, and Test.crashes checks that a closure panics. The package also holds the runner and its reporters, so koja test is a Koja program. It links only for koja test and koja check, so a build cannot name Test.Failure or leave an assert in production code.
  • koja test flags. --reporter <name> selects dots (the default), trace, or json, and --trace stays as an alias for --reporter trace. The json reporter writes one event per line to stderr, or to a file with --out <path>, for CI and editors, with each test’s time as integer microseconds. The human reporters print the time in the unit that fits, 452µs, 3ms, or 1.2s. --timeout <ms> sets the deadline for each test. --backend {interpreter,llvm} picks the backend the way koja run does.
  • The interpreter calls @extern "C" functions. A symbol without a built-in handler resolves through the dynamic loader, in the @link library as a shared library under the project root, on the loader’s search path, or in the running process, and runs through libffi with the declared signature. Every FFI-admissible type crosses the boundary, and a non-finite float return traps as it does in compiled code. koja run and koja test now interpret an FFI project whose libraries are shared libraries.
  • Instant, a point on the monotonic clock and the type for elapsed time: started = Instant.now() then started.elapsed(). It counts nanoseconds and does not move when the system time changes.
  • Timestamp, a Duration since the Unix epoch. Timestamp.new(value, unit) stores an epoch value in the unit it arrived in, now() reads the clock in microseconds, and the since_epoch field converts on the way out, so t.since_epoch.to_seconds() is Unix time. It replaces DateTime.
  • Calendar and zone types on top of Timestamp. The DateTime name returns as the zoned type, see the Removed entry below.
    • Date, Time, and LocalDateTime, civil values with no zone. Date.new and Time.new check every field, so a value is always valid. Date has day_of_week, day_of_year, plus_days, plus_months (clamping to the month’s end), plus_years, and the epoch-day conversions. Time has microsecond precision and converts to and from a Duration since midnight. Weekday runs Monday to Sunday.
    • TimeZone, an enum with UTC, Fixed(TimeZone.Offset), and Named(TimeZone.Rules). TimeZone.Offset is a distance from UTC within -18:00..+18:00, with the constant TimeZone.Offset.UTC.
    • TimeZone.Rules, the data behind a named zone. It holds the IANA identifier, the offset before the first transition, a sorted list of TimeZone.Transition values, and a TimeZone.Rule for the years after the last one. TimeZone.Rule holds the standard offset and an optional TimeZone.Rule.Daylight with the daylight offset and two TimeZone.Rule.Point values, the POSIX Mm.w.d/time form. The stdlib evaluates the rules and ships no data. The koja-lang/tz package embeds the IANA database and builds a Named zone for an identifier such as America/Chicago.
    • TimeZone.Resolution, returned wherever a civil time is placed in a zone: Unique, Gap, or Ambiguous, with compatible(), earlier(), later(), and unique(). LocalDateTime.in_zone resolves against the offsets in force around the clock time, so a Named zone reports its skipped hour as Gap and its repeated hour as Ambiguous. UTC and Fixed always resolve to Unique.
    • DateTime, a Timestamp viewed in a TimeZone. date, time, local, and offset compute from the two fields. plus and minus take a Duration and are exact. plus_days and plus_months keep the clock time and return a TimeZone.Resolution. Two values are equal when they name the same instant in the same zone.
    • A format protocol per type, Date.Format, Time.Format, LocalDateTime.Format, and DateTime.Format, each with a format_* and a parse_* method. Every type has to_string(format) and parse(text, format) that forward to it, with ISO8601.Extended as the default format, so Date.parse("2026-09-16") and date.to_string() need no argument.
    • ISO8601, the stdlib format, with Extended (2026-09-16T17:39:00Z) and Basic (20260916T173900Z) variants. A DateTime in Extended form is RFC 3339. A parse reports an out-of-range field with that field’s error and any other shape as Malformed.
  • A protocol can nest under a type, in the body (protocol Format inside struct Date) or at the top level with a qualified name (protocol Date.Format). It is referenced as Date.Format in impl headers, bounds, and conformance lists. Several types can each own a Format, and one type can implement all of them.
  • A constant can nest under a struct, enum, or builtin, in the body (const ZERO = ... inside struct Duration) or at the top level with a qualified name (const Duration.ZERO = ...). It is read as Duration.ZERO everywhere, the owner’s body included, and can be a field default. The stdlib adds Int.MAX, Int.MIN, Duration.ZERO, Timestamp.UNIX_EPOCH, IPAddress.ANY, and IPAddress.LOOPBACK.
  • koja deps outdated lists the git dependencies whose remote has something newer than the pin. A tag pin is compared against the remote’s X.Y.Z tags, with an optional v, and prints tz 2026.3.0 -> 2026.4.0. A branch, rev, or default-branch pin is compared against the remote head. The command exits 1 when anything is outdated, so CI can run it, and never writes koja.lock.
  • alias binds a package-level function or constant, not only a type. alias Test.require makes require(x) and &require/1 available in the file, every arity included, and alias JSON.decode as parse renames it. The local name keeps the case of its target.
  • New language server features:
    • Find references lists every use of a function, type, constant, local, or type parameter across the project.
    • Rename rewrites every use in one edit. It refuses, with a reason, when the program has errors, when the symbol is declared in the stdlib, or when the symbol is self or a method that implements a protocol.
    • Document highlight marks the uses in the open file and tells reads from writes.
    • Inlay hints show the inferred type after a binding, a closure parameter, or a tuple destructure that has no annotation, and the parameter name before each positional argument.

Changed

  • Breaking change. Duration is a value and a Duration.Unit, from Nanoseconds to Hours, built with Duration.new(30, Duration.Unit.Seconds). It stores what the caller wrote, so no constructor can overflow. Two durations are equal when they cover the same span, and plus and minus return the finer unit. The accessors spell out their unit, to_hours through to_nanoseconds, and truncate toward a coarser unit. Duration.from_secs(n) becomes Duration.new(n, Duration.Unit.Seconds), and millis() becomes to_milliseconds().
  • Hover, go-to-definition, and completion keep working while the program has type errors. Before, an error anywhere in the project turned them off until it was fixed.
  • Hover shows a function signature the way koja format writes it. A long parameter list breaks one parameter per line, self stays bare, and a -> T ! E return keeps that spelling.
  • koja test runs on the interpreter by default and falls back to LLVM when the project declares a C extern the interpreter cannot resolve, which now means a @link library that exists only as a static archive. Pass --backend llvm for the native run.
  • koja run --backend=interpreter and koja test --backend interpreter on a project with an extern the loader cannot find report every unresolved symbol up front, with the library name and the loader’s reason, instead of failing at the first call.
  • koja test runs each test in its own process. A crash or a hang is one failed test instead of the end of the run. The deadline is per test and defaults to 60 seconds, replacing the 60 second limit on the whole run.
  • koja test output follows the compiler’s diagnostics style. --trace groups tests under their file, type, Type: Protocol, or extend target. A failed assertion draws its source line with the expression underlined and both operands labeled in the pretty style, or prints one file:line:column: failure: ... line in the short style. --diagnostics, KOJA_DIAGNOSTICS, --no-color, and NO_COLOR apply to koja test as they do to koja check, so piped output carries no color.
  • koja format keeps the members of a type body in source order. A test block, a nested type, and a function stay where the author put them instead of grouping by kind.
  • In assert a == b the right operand is typed from the left, so a literal or a unit variant on the right takes the left’s type. assert count == 0 against a UInt32 and assert stack.peek() == Option.None now typecheck without an annotated local.
  • Errors about a declaration, such as already defined, underline its name instead of the whole declaration.
  • Errors that involve a second declaration show where it is. already defined shows the earlier definition, a duplicate alias shows the earlier alias, and an error about a priv item shows where it is declared. The terminal draws the second location under the first, and editors link to it.
  • In the editor, the outline view and go-to-definition select the name of a function, type, constant, or protocol instead of the whole declaration.

Deprecated

  • @test is deprecated and will be removed in 0.20. Every annotation reports a warning that points at the test "description" block. The function still runs under koja test until then.

Fixed

  • A binary pattern literal segment wider than 64 bits, such as <<0::80, rest: Binary>>, now matches correctly. The interpreter panicked on the width and compiled code compared only part of the segment, so a value with a set high byte matched <<0::80>>.
  • A receive in a helper method of a process whose message type includes Process.ExitSignal no longer fails LLVM code generation with local slot not registered.
  • koja format renders a binary pattern segment whose value or size is an expression, such as <<head::len * 8>>. The formatter wrote <expr> in its place.
  • A generic parameter can have a default, fn parse<F: Reader>(text: String, format: F = Plain.Decimal). Calling it without the argument failed with “cannot infer type parameter F” because the shorter arity kept a type parameter no argument could bind. The type now comes from the default.
  • koja format keeps the \#{ escape in a string pattern. The formatter dropped the backslash, so the output re-parsed as an interpolation.
  • A type declared twice reports one error. It also no longer reports an error for each duplicate derived Debug and Equality method.
  • The underline in a terminal error no longer runs one column past the end of the code it points at.
  • A struct constant with an enum field, such as const ZERO = Span{value: 0, unit: Unit.Seconds}, and an enum constant read from two functions both compile under LLVM. Each failed module verification before.
  • -9223372036854775808 compiles as the smallest Int. The literal was rejected because its magnitude alone does not fit.

Removed

  • Breaking change. DateTime as the epoch time type is removed. That role moves to Timestamp, and the name now belongs to the zoned calendar type in the Added section. DateTime.now().timestamp_millis() becomes Timestamp.now().since_epoch.to_milliseconds(), and two wall-clock reads subtracted to time something become one Instant. Check every DateTime annotation by hand. The new DateTime.now takes a TimeZone, so a zero-argument call no longer compiles, but an annotation that never calls a method compiles against the new type and means a different thing.
  • Breaking change. The unless keyword is removed. Write if not cond instead. not binds tighter than and and or, so a compound condition needs parentheses (if not (a and b)) or De Morgan (if a != x and b != y). The word stays reserved, and the parser reports the replacement when it meets an old unless block.
  • Breaking change. JSON.StringBuilder is removed after its 0.18.2 deprecation. Accumulate with <> or use String.join.
  • Breaking change. IPAddress.v4?() and IPAddress.v6?() are removed after their 0.18.0 deprecation. Compare address.version with IPAddress.Version.V4 or IPAddress.Version.V6.
  • Breaking change. IPAddress.any() and IPAddress.loopback() are removed. They are replaced by the constants IPAddress.ANY and IPAddress.LOOPBACK.