Skip to content

v0.16.0

Choose a tag to compare

@hpopp hpopp released this 04 Aug 01:34
· 143 commits to main since this release
81cc16e

Added

  • Anonymous tuples. Build with (a, b), annotate as (Int, String), take apart with destructuring assignment (x, y) = pair or match patterns.
  • Error channel notation for fallible functions: -> T ! E declares a function returning Result<T, E>, with success values wrapping in Result.Ok automatically.
  • try expr unwraps an Ok value or propagates the Err out of the enclosing function, widening the error into a declared union such as ! ParseError | NetError.
  • fail expr returns an error from a fallible function, as sugar for return Result.Err(expr).
  • expr rescue e -> handler handles one expression's error inline, producing the Ok value or the handler's result.
  • Custom CLI tasks. A package's [tasks] table maps package-prefixed names to types implementing the new Koja.Task protocol, runnable with koja run <task.name> [-- args] from the project or any project depending on it.
  • koja tasks lists every task exported by the project, its dependencies, and the toolchain.
  • Directory functions on File: mkdir (single level), mkdir_p (creates missing parents), rmdir (removes an empty directory), and dir? (true only for directories).
  • Nested types can now be declared inside the owner's body, equivalent to the qualified top-level form struct Owner.Nested.
  • The @deprecated "message" annotation marks a declaration as deprecated, warning at every use site with the given migration guidance.
  • Tuples compare with ==/!=, print and interpolate like any other value, and can be members of type unions.

Changed

  • Breaking change. try, fail, and rescue are now reserved keywords and can no longer be used as identifiers.
  • Breaking change. Result.then has been removed. Use try for unwrap-or-propagate chains.
  • Breaking change. Standard library APIs now use anonymous tuples for list pops, datagram receives, JSON object entries, parser results, and process envelopes instead of Pair.
  • Breaking change. The manifest name is now the package's lowercase snake_case identity, and code-facing PascalCase namespaces are derived from it (my_app -> MyApp) or declared with the new namespace field.
  • Breaking change. Multiline string content must start on the line after the opening """, and the closing """ must sit on its own line.
  • Breaking change. Explicit return values are now typechecked against the declared return type, a bare return in a valued function is an error, and return <value> is rejected in Unit functions and scripts.
  • Breaking change. Reading a local that is not assigned on every path to the read is now a compile error, instead of silently loading an uninitialized value.
  • Breaking change. Comparing tuples that contain a closure- or union-typed element is now a compile error, instead of silently skipping those elements.
  • Kernel.exit is now typed as divergent, so a match arm or function body can end in Kernel.exit(...) without a dummy tail value.
  • koja new is now a task written in Koja itself, exported by the stdlib as koja.new and runnable anywhere, including outside a project.
  • Compiler errors and warnings now print their file:line:column location with a source snippet and caret underline.
  • Diagnostics render in a pretty terminal format or a machine-friendly one-line format, selectable via --diagnostics=pretty|short or the KOJA_DIAGNOSTICS environment variable (defaulting by whether stderr is a terminal).

Fixed

  • koja format now exits with an error code when a file fails to parse, instead of printing the error and reporting success.
  • koja format now preserves multiline string literals exactly, including nested indentation and embedded quotes, instead of corrupting their content.
  • A conditional top-level return in a script no longer crashes koja run --backend=llvm.