# Changelog

## 0.11.0

Released 2026-05-28.

### Meta

- Roto is now on Codeberg! The repository is now located at
  <https://codeberg.org/NLnetLabs/roto>.

### Language

#### Breaking changes

- There are a couple of syntax changes. These all bring Roto a bit closer to
  Rust, which makes Roto a less surprising for new users. The comment syntax has
  now changed twice and we apologize for the churn that creates. See [this forum
  post](https://community.nlnetlabs.nl/t/proposed-syntax-changes-for-0-11/3343)
  for the reasoning behind these changes.

  - Change comment syntax from `#` to `//`. ([#384](https://codeberg.org/NLnetLabs/roto/pulls/384))
  - Change `variant` keyword to `enum`. ([#384](https://codeberg.org/NLnetLabs/roto/pulls/384))
  - Change match arm syntax from `->` to `=>`. ([#384](https://codeberg.org/NLnetLabs/roto/pulls/384))
  - Change boolean negation operator from `not` to `!`. ([#384](https://codeberg.org/NLnetLabs/roto/pulls/384))
  - Change match guard syntax from `|` to `if`. ([#387](https://codeberg.org/NLnetLabs/roto/pulls/387))

```roto
// This is the new comment syntax!
// And here is an enum (previously variant):
enum Direction {
    Left,
    Right,
}

fn choose_direction(choice: Direction, dont_go_left: bool) {
    match choice {
        Left if !dont_go_left => print("left!"),
        Right => print("right!"),
        _ => print("unsure!"),
    }
}
```

- It is not allowed anymore to chain comparison operators (`==`, `!=`, `<=`,
  `>=`, `<`, `>`) without parentheses. This ensures that the associativity of
  these operators is always clear. ([#353](https://codeberg.org/NLnetLabs/roto/pulls/353))

```roto
fn main() {
    let x = false == true == false;   // now a parse error
    let y = (false == true) == false; // but this is allowed
}
```

- Many operators now parse left-associative instead of right-associative.
  This shouldn't normally make much of a difference, but in some edge cases (for
  example with floats) it matters. ([#353](https://codeberg.org/NLnetLabs/roto/pulls/353))

#### Added

- Constants can now be defined in Roto scripts. They are computed at
  compile-time and can be accessed in functions and other constants. ([#371](https://codeberg.org/NLnetLabs/roto/pulls/371))

```roto
const FOO: u32 = 10 + 5;
```

- The `==` and `!=` operators can now be used on all types, including registered
  types, records and enums. ([#366](https://codeberg.org/NLnetLabs/roto/pulls/366))

```roto
record Vec2 {
    x: f32,
    y: f32,
}

fn main() {
    let a = Vec2 { x: 1.0, y: 1.0 };
    let b = Vec2 { x: 1.0, y: 1.0 };
    print(f"a and b are equal: {a == b}");
}
```

- Blocks (`{}`) can now be used as expressions. This is particularly useful
  for complex definition of constants. Note that an empty pair of braces `{}`
  still parses as an anonymous record, not as an empty block.
  ([#384](https://codeberg.org/NLnetLabs/roto/pulls/384))

```roto
const FOO: u32 = {
    let a = 10;
    a + 5
};
```

- Added the remainder operator `%` for integers. Thanks, @Wrimo!
  ([#364](https://codeberg.org/NLnetLabs/roto/pulls/364))

```roto
fn is_even(x: u64) -> bool {
    x % 2 == 0
}
```

- Added the compound assignment operators `+=`, `-=`, `*=`, `/=` and `%=`.
  ([#404](https://codeberg.org/NLnetLabs/roto/pulls/404))

```roto
fn main() {
    let x = 10;
    x += 3;  // x == 13
    x -= 2;  // x == 11
    x *= 4;  // x == 44
    x /= 2;  // x == 22
    x %= 10; // x == 2
}
```

- Added `List.contains` and `List.index` methods to find elements in a list.
  ([#369](https://codeberg.org/NLnetLabs/roto/pulls/369))

```roto
fn main() -> bool {
    let l = ["A", "B", "C", "D"];
    print(f"list contains B: {l.contains("B")}");
    match l.index("C") {
      Some(idx) => print(f"index of C: {idx}"),
      None => print("no C in list"),
    }
}
```

- Added `List.join` method to join strings in a list into a single string.
  ([#357](https://codeberg.org/NLnetLabs/roto/pulls/357))

```roto
fn main() -> bool {
    let l = ["one", "two", "three", "four"];
    print(l.join(", ")); // prints "one, two, three, four"
}
```

- Added `String.from_chars`, `String.split`, `String.replace` methods.
  ([#357](https://codeberg.org/NLnetLabs/roto/pulls/357))
- Added `String.trim`, `String.trim_start`, `String.trim_end`,
  `String.strip_prefix`, `String.strip_suffix` methods. Thanks, @erikwastaken!
  ([#377](https://codeberg.org/NLnetLabs/roto/pulls/377))
- Added `String.splitn` and `String.rsplitn` methods. Thanks, @kaathewise!
  ([#405](https://codeberg.org/NLnetLabs/roto/pulls/405))
- Added `String.bytes`, `String.chars`, `String.lines` methods to give a view
  over a string indexed by the respective unit. ([#357](https://codeberg.org/NLnetLabs/roto/pulls/357))

```roto
fn main() -> bool {
    let s = "this is line one\nthis is line two";
    match s.lines().get(0) {
      Some(line) => print(line),
      None => print("no line"),
    }
}
```

#### Bug fixes

- Fixed a bug that caused some record fields not being when cloned. ([#362](https://codeberg.org/NLnetLabs/roto/pulls/362))

### Crate

#### Breaking changes

- All registered types are now required to implement `PartialEq`. ([#366](https://codeberg.org/NLnetLabs/roto/pulls/366))
- All registered types are now required to implement `Send + Sync`. ([#371](https://codeberg.org/NLnetLabs/roto/pulls/371))
- The Rust type corresponding to a `String` in Roto is now `RotoString` instead
  of `Arc<str>`. For compatibility, `RotoString` can be converted from and into
  `Arc<str>` with `into`. This change allows us to optimize the string type
  without breaking the API again at a later stage. ([#357](https://codeberg.org/NLnetLabs/roto/pulls/357))

```rust
// Roto 0.10
let f = pkg.get_function::<fn(Arc<str>) -> Arc<str>>("main").unwrap();

// Roto 0.11
let f = pkg.get_function::<fn(RotoString) -> RotoString>("main").unwrap();
```

#### Added

- `List<T>` now implements `FromIterator`. This means that you can `collect`
  into a `List`. ([#357](https://codeberg.org/NLnetLabs/roto/pulls/357))
- `List<T>` now implements `From<Vec<T>>`, `From<&[T]>` and `From<[T; N]>`.
  ([#389](https://codeberg.org/NLnetLabs/roto/pulls/389))
- `List<T>` now implements `IntoIterator`. ([#389](https://codeberg.org/NLnetLabs/roto/pulls/389))
- `List<T>` now implements `Debug`. ([#389](https://codeberg.org/NLnetLabs/roto/pulls/389))

#### Bug fixes

- Rename fields of `TypeMismatch` so that `unwrap` after `get_function` gives a
  clearer error message. Thanks, @Teufelchen1! ([#368](https://codeberg.org/NLnetLabs/roto/pulls/368))
- Change `unwrap`s generated by the `library!` macro to `expect` to allow it in
  cases where the `unwrap_used` lint is active. Thanks, @algernon! ([#381](https://codeberg.org/NLnetLabs/roto/pulls/381))
- Roto no longer fails to compile if `log`'s `kv_serde` feature is enabled. ([#394](https://codeberg.org/NLnetLabs/roto/pulls/394))
- Associated constants are now included in generated documentation. ([#410](https://codeberg.org/NLnetLabs/roto/pulls/410))

### Documentation

- New chapter "Writing Roto". ([#380](https://codeberg.org/NLnetLabs/roto/pulls/380))
- Many fixes and improvements due to review by @SynchroM. Thanks! ([#397](https://codeberg.org/NLnetLabs/roto/pulls/397), [#398](https://codeberg.org/NLnetLabs/roto/pulls/398))
- Add instructions for Sublime Text support to the docs. Thanks, @Teufelchen1! ([#367](https://codeberg.org/NLnetLabs/roto/pulls/367))
- Most code samples in CI are now tested, which should make them more reliable
  and always up to date. ([#380](https://codeberg.org/NLnetLabs/roto/pulls/380), [#400](https://codeberg.org/NLnetLabs/roto/pulls/400))

### Tooling

- Updated Sublime Text syntax definition. ([#401](https://codeberg.org/NLnetLabs/roto/pulls/401))
- Updated VS Code syntax definition. ([#401](https://codeberg.org/NLnetLabs/roto/pulls/401))
- Updated tree-sitter definition at <https://codeberg.org/NLnetLabs/tree-sitter-roto>.

## 0.10.0

Released 2026-01-14.

### Meta

- We now have a `CONTRIBUTING.md`, `TESTING.md` and `SECURITY.md`. ([#333](https://codeberg.org/NLnetLabs/roto/pulls/333))

### Language

#### Breaking changes

- Changed the `type` keyword to `record`. ([#297](https://codeberg.org/NLnetLabs/roto/pulls/297))

```roto
# Roto 0.9.0
type Vec2 {
    x: f32,
    y: f32,
}

# Roto 0.10.0
record Vec2 {
    x: f32,
    y: f32,
}
```
- The `LOCALHOSTV4` and `LOCALHOSTV6` constants are not longer global but live
  under `IpAddr` as associated constants. ([#292](https://codeberg.org/NLnetLabs/roto/pulls/292))

#### Added

- Lists are now supported! See the documentation for more information. ([#301](https://codeberg.org/NLnetLabs/roto/pulls/301))

```roto
let x: List[i32] = [1, 2, 3];
let y = [4, 5, 6];
let z = x + y;
```

- Roto now has `variant` types. These are much like `enum` types in Rust. ([#293](https://codeberg.org/NLnetLabs/roto/pulls/293))

```roto
variant Either[L, R] {
    Left(L),
    Right(R),
}
```

- Record types can now have type parameters. ([#298](https://codeberg.org/NLnetLabs/roto/pulls/298))

```roto
record Pair[A, B] {
    a: A,
    b: B,
}
```

- In addition to `while` loops, there are now `for` loops to iterate over lists. ([#346](https://codeberg.org/NLnetLabs/roto/pulls/346))

```roto
let total = 0;
for x in [1, 2, 3, 4] {
    total = total + x;
}
```

- The `StringBuf` type was added to allow building strings character by
  character more efficiently. ([#300](https://codeberg.org/NLnetLabs/roto/pulls/300))

```roto
let buf = StringBuf.new();
buf.push_char('H');
buf.push_string("ello, World");
buf.push_char('!');
let s: String = buf.as_string();
```

- The `char` type was added, representing a single Unicode code point. ([#300](https://codeberg.org/NLnetLabs/roto/pulls/300))

```roto
let a: char = 'a';
```

- The repository now contains a basic Sublime Text grammar. This can be used 
  for syntax highlighting in Sublime Text, VS Code, Typst and other
  applications. ([#291](https://codeberg.org/NLnetLabs/roto/pulls/291))

- If you use common keywords from other languages, Roto will now hint about what
  the appropriate Roto keyword is. ([#322](https://codeberg.org/NLnetLabs/roto/pulls/322))

- If you try to use `//` or `--` for comments, Roto will hint that you should
  use `#`. ([#322](https://codeberg.org/NLnetLabs/roto/pulls/322))

#### Bug fixes

- Error messages with non-ASCII characters now display correctly. Thanks @LevitatingBusinessMan! ([#325](https://codeberg.org/NLnetLabs/roto/pulls/325))
- Type errors are now slightly more informative by printing the id's associated
  with type variables, instead of printing just an `_`. ([#308](https://codeberg.org/NLnetLabs/roto/pulls/308))

### Crate

#### Breaking changes

- The MSRV is now 1.85. ([#288](https://codeberg.org/NLnetLabs/roto/pulls/288))
- The context of a `Runtime` is now a type parameter of the `Runtime` type. ([#274](https://codeberg.org/NLnetLabs/roto/pulls/274))
- The `Reflect` trait has been renamed to `Value`. ([#304](https://codeberg.org/NLnetLabs/roto/pulls/304))
- `Runtime` and `Package` now have a type parameter `C`, which can be either `NoCtx` or
  `Ctx<T>`, representing whether it has a context type. ([#274](https://codeberg.org/NLnetLabs/roto/pulls/274))
- The method `Runtime::register_context_type` has been replaced with
  `Runtime::with_context_type` with slightly different behaviour. Instead of
  taking a mutable reference to the runtime, it takes it by value and returns
  it. ([#274](https://codeberg.org/NLnetLabs/roto/pulls/274))

```rust
// Roto 0.9.0
let mut rt = Runtime::new();
rt.register_context_type::<MyContext>();

// Roto 0.10.0
let rt = Runtime::new().with_context_type::<MyContext>();
```

- `Package::get_function` no longer has a type parameter for the context type. ([#274](https://codeberg.org/NLnetLabs/roto/pulls/274))

```rust
// Roto 0.9.0
let f = pkg.get_function::<MyContext, fn(i32) -> i32>();

// Roto 0.10.0
let f = pkg.get_function::<fn(i32) -> i32>();
```

- Calling a `TypedFunc` without a context no longer requires the annoying first
  argument `&mut ()`. ([#274](https://codeberg.org/NLnetLabs/roto/pulls/274))

```rust
// Roto 0.9.0
let f = pkg.get_function::<(), fn(i32) -> i32>();
f.call(&mut (), 5)

// Roto 0.10.0
let f = pkg.get_function::<fn(i32) -> i32>();
f.call(5)
```

- Similarly, the `Package::run_tests` method no longer takes an argument if there is no context argument.

```rust
// Roto 0.9.0
pkg.run_tests(());

// Roto 0.10.0
pkg.run_tests();
```

#### Added

- It's now possible to register associated constants. ([#292](https://codeberg.org/NLnetLabs/roto/pulls/292))

```rust
let lib = library! {
    type MyType = Val<MyType>;
    impl Val<MyType> {
        /// Associated constant FOO!
        const FOO: usize = 0;
    }
}
```

- The `RotoFunc` trait is now exposed. ([#299](https://codeberg.org/NLnetLabs/roto/pulls/299))
- The `selinux-fix` feature flag is added to allow running Roto under SE Linux
  systems. This might become the default behaviour in the future. Thanks
  @LevitatingBusinessMan! ([#279](https://codeberg.org/NLnetLabs/roto/pulls/279))

#### Bug fixes

- Fixed a bug which prevented registering types in a module. ([#315](https://codeberg.org/NLnetLabs/roto/pulls/315))
- The `library!` macro will emit more precise errors when it fails to parse. ([#306](https://codeberg.org/NLnetLabs/roto/pulls/306))
- The `library!` macro will be more precise in reporting the actual problems
  when trait resolution fails on the generated code. ([#318](https://codeberg.org/NLnetLabs/roto/pulls/318))
- Tests are now sorted before being run. ([#319](https://codeberg.org/NLnetLabs/roto/pulls/319))
- We removed some unused dependencies from our dependency tree, though this only
  concerned dev-dependencies. ([#337](https://codeberg.org/NLnetLabs/roto/pulls/337))

### Documentation

- Documentation was extended and improved a lot in many PRs.

## 0.9.0

Released 2025-10-15.

### Language

#### Breaking changes

- Enums and records can no longer be compared with `==` and `!=`. This was
  previously allowed, but the generated code might have been wrong. This
  feature might be brought back with a proper implementation later. ([#289](https://codeberg.org/NLnetLabs/roto/pulls/289))

#### Added

- Added `addr`, `min_addr`, `max_addr`, `len` and `eq` methods to `Prefix`. ([#289](https://codeberg.org/NLnetLabs/roto/pulls/289))

#### Bug fixes

- Fixed a case where we dropped an uninitialized value that occurred when an
  expression that might return was assigned to a variable. ([#280](https://codeberg.org/NLnetLabs/roto/pulls/280))
- Fixed some miscompilations around using the `==` and `!=` operators on
`Prefix`. ([#289](https://codeberg.org/NLnetLabs/roto/pulls/289))
- The `to_string` method of expressions in f-strings are now resolved later, which
  avoids some cryptic error messages. ([#281](https://codeberg.org/NLnetLabs/roto/pulls/281))

### Crate

#### Breaking changes

- Make `RotoError` a private type. Thanks @you-win! ([#270](https://codeberg.org/NLnetLabs/roto/pulls/270))

#### Added

- Make the `RegistrationError` type public. ([#271](https://codeberg.org/NLnetLabs/roto/pulls/271))
- Implement `std::error::Error` for `FunctionRetrievalError`,
  `RegistrationError`. Thanks @you-win! ([#270](https://codeberg.org/NLnetLabs/roto/pulls/270))

#### Bug fixes

- Roto now works correctly again when it is compiled with static linking (such
  as with the musl target). ([#286](https://codeberg.org/NLnetLabs/roto/pulls/286))

## 0.8.0

Released 2025-10-06.

### Language

#### Bug fixes

- The trailing comma of match arms is now optional, as it was supposed to be. ([#253](https://codeberg.org/NLnetLabs/roto/pulls/253))

- Fix an issue where the types of float literals weren't properly resolved. ([#258](https://codeberg.org/NLnetLabs/roto/pulls/258))

### Crate

#### Breaking changes

- The functions `SourceFile::read`, `FileTree::read`, `FileTree::single_file`
  and `FileTree::directory` now return `Result` and will no longer panic on
  I/O errors. Thanks @algernon! ([#250](https://codeberg.org/NLnetLabs/roto/pulls/250))

- All custom registered types now _always_ need to wrapped in `Val`. This fixes
  some bugs around registered types and should make it easier to understand when
  `Val` has to be used. Below is a diff illustrating how to migrate. ([#247](https://codeberg.org/NLnetLabs/roto/pulls/247))

```diff
 runtime
-    .register_clone_type::<AddrRange>("A range of IP addresses")
+    .register_clone_type::<Val<AddrRange>>("A range of IP addresses")
     .unwrap();

 // Register the contains method with a docstring
-#[roto_method(runtime, AddrRange)]
+#[roto_method(runtime, Val<AddrRange>)]
 fn contains(range: Val<AddrRange>, addr: Val<IpAddr>) -> bool {
     range.min <= *addr && *addr <= range.max
 }
```

#### New

- The CLI can now run other functions than `main`. Thanks @pieterlexis! ([#261](https://codeberg.org/NLnetLabs/roto/pulls/261))

- It is now possible to register closures. ([#248](https://codeberg.org/NLnetLabs/roto/pulls/248))

- There is an entirely new registration API using the new `library!` macro.
  The previous `Runtime::register_*` methods are all still available, but
  deprecated. ([#254](https://codeberg.org/NLnetLabs/roto/pulls/254) and [#262](https://codeberg.org/NLnetLabs/roto/pulls/262))

```rust
use roto::{Runtime, Val, library};

let lib = library! {
     /// A vector with `x`, `y` and `z` components
     #[clone] type Vec3 = Val<Vec3>;

    impl Val<Vec3> {
        /// Scale this `Vec3` by `r` and return the result
        fn scale(self, r: f32) -> Self {
            Val(self.0 * r)
        }
    }

    /// A vector with all zeroes.
    const ZERO: Val<Vec3> = Val(Vec3 { x: 0.0, y: 0.0, z: 0.0 });
};

let rt = Runtime::from_lib(lib).unwrap();
```

### Documentation

#### New

- The generated documentation is now spread out over multiple pages. It
  generates a page per module and per type. ([#254](https://codeberg.org/NLnetLabs/roto/pulls/254))
- There is a new "Syntax Overview" page in the documentation. ([#263](https://codeberg.org/NLnetLabs/roto/pulls/263))
- Added the following concepts to the language reference: identifiers, booleans,
  `match`, local variables and string formatting. ([#263](https://codeberg.org/NLnetLabs/roto/pulls/263))

#### Bug fixes

- Fixed some examples so that they are consistent with the text and ensure that
  they compile. Thanks @pieterlexis! ([#260](https://codeberg.org/NLnetLabs/roto/pulls/260))
- Fixed many spelling errors in the manual, API docs and the rest of the
  codebase. Thanks @jsoref! ([#264](https://codeberg.org/NLnetLabs/roto/pulls/264))

## 0.7.1

Released 2025-09-26.

## Language

### Bug fixes

- `{{` and `}}` are now unescaped in f-strings. ([#257](https://codeberg.org/NLnetLabs/roto/pulls/257))
- `\u{xxxx}` and `\U{xxxx}` are now properly parsed in f-strings. ([#257](https://codeberg.org/NLnetLabs/roto/pulls/257))
- Fix an issue where function calls could not be used directly in f-strings. ([#257](https://codeberg.org/NLnetLabs/roto/pulls/257))

## 0.7.0

Released 2025-08-25.

This release features a new documentation website available at
<https://roto.docs.nlnetlabs.nl>. If you're new to Roto, it is a great place
to start learning. It is a work in progress, so please give us feedback!

We have also made a tree-sitter grammar for Roto, that is now good enough to
try out: <https://github.com/NLnetLabs/tree-sitter-roto>.

### Language

#### Breaking changes

- The `function` keyword was changed into the `fn` keyword. ([#213](https://codeberg.org/NLnetLabs/roto/pulls/213))
- The `Optional` type has been renamed to `Option`. ([#216](https://codeberg.org/NLnetLabs/roto/pulls/216))
- The `Unit` type has been renamed to `()`. It can also be constructed with
  `()` ([#225](https://codeberg.org/NLnetLabs/roto/pulls/225))

#### New

- Roto now allows multiple items to be imported on a single line. Thanks
  @Wrimo! ([#180](https://codeberg.org/NLnetLabs/roto/pulls/180))

```roto
import foo.{bar1, bar2};
import foo.{bar.fn1, bar2.{fn2, fn3}};
```

- Variants, methods and static methods can now be imported directly. ([#202](https://codeberg.org/NLnetLabs/roto/pulls/202))

```roto
# Import variants
import Option.{Some, None};

# Import a method (as `append`)
import String.append;

# Import a static method (as `new`)
import Prefix.new;

fn foo() {
    let x = Some(10);
    let y = append("race", "car");
    let z = new(1.1.0.0, 16);
}
```

- Methods can now be called as if they were static functions. ([#202](https://codeberg.org/NLnetLabs/roto/pulls/202))

```roto
fn foo() {
    # previously:
    let x = "race".append("car");

    # now also possible:
    let y = String.append("race", "car");
}
```

- Roto now has its first looping construct: `while`. ([#194](https://codeberg.org/NLnetLabs/roto/pulls/194))

```roto
fn factorial(x: u64) -> u64 {
    let i = 1;
    let n = 1;
    while i <= x {
        n = n * i;
        i = i + 1;
    }
    n
}
```

- A new `?` operator, will return a `Option.None` value or yield the value
  inside `Option.Some`, much like the same operator in Rust. ([#195](https://codeberg.org/NLnetLabs/roto/pulls/195))

```roto
fn small(x: i32) -> i32? {
    if x < 10 {
        Some(x)
    } else {
        None
    }
}

fn foo(x: i32, y: i32) -> i32? {
    let z = small(x)? + small(y)?;
    Some(z)
}
```

- The unary minus operator has been added to negate signed integers and
  floating point numbers. ([#196](https://codeberg.org/NLnetLabs/roto/pulls/196))

```roto
fn abs(x: i32) -> i32 {
    if x { x } else { -x }
}
```

- It is now possible to add a type annotation on `let` bindings. ([#197](https://codeberg.org/NLnetLabs/roto/pulls/197))

```roto
fn foo() -> u64 {
    let x: u64 = 10;
    x
}
```

- Python-like f-strings have been added. This is a basic implementation
  that is still rough around the edges. All primitives and registered types
  with a `to_string` method can be put in a string prefixed with `f`. Any
  expression evaluating to such a type is valid. See issue [#244](https://codeberg.org/NLnetLabs/roto/pulls/244) for the
  current limitations. ([#220](https://codeberg.org/NLnetLabs/roto/pulls/220))

```roto
fn foo() -> String {
    let x: u64 = 10;
    f"The value of x is {x} and twice x is {2 * x}"
}
```

#### Bug fixes

- Roto now has an additional compiler pass: MIR. A lot of the code generation
  was rewritten from scratch for this change. With the MIR we model values
  passed to Roto in a more robust and several memory safety issues were fixed
  in the process. ([#182](https://codeberg.org/NLnetLabs/roto/pulls/182))

- The error message for multiple item declarations with the same name have been
  improved, especially when two tests with the same name are declared. ([#191](https://codeberg.org/NLnetLabs/roto/pulls/191))

- The error messages for unresolved paths have been improved. ([#198](https://codeberg.org/NLnetLabs/roto/pulls/198))

- String literals are now properly unescaped. ([#200](https://codeberg.org/NLnetLabs/roto/pulls/200))

- The previous implementation of constants turned out to be unsound, so a new
  implementation should fix memory safety issues around them. ([#208](https://codeberg.org/NLnetLabs/roto/pulls/208))

- The `Reflect` and `RotoFunc` traits are now sealed because they should not
  be implemented by downstream crates. ([#214](https://codeberg.org/NLnetLabs/roto/pulls/214))

- Fixed a bug where it wasn't possible to use multiple `not` operators. ([#195](https://codeberg.org/NLnetLabs/roto/pulls/195))

- Fixed an incorrect error message for `==` that showed the wrong type as
  expected. ([#242](https://codeberg.org/NLnetLabs/roto/pulls/242))

### Crate

#### Breaking changes

- The CLI is now gated by a `cli` feature flag. ([#175](https://codeberg.org/NLnetLabs/roto/pulls/175))
- Logging is now gated by a `logger` feature flag. ([#175](https://codeberg.org/NLnetLabs/roto/pulls/175))
- The fields of `Runtime` are now private. ([#193](https://codeberg.org/NLnetLabs/roto/pulls/193))
- `Runtime` is passed by reference instead of moved to the compilation procedure,
  allow for easier reuse across multiple compilations. ([#193](https://codeberg.org/NLnetLabs/roto/pulls/193))
- Registered constants are now required to be `Send + Sync`. ([#208](https://codeberg.org/NLnetLabs/roto/pulls/208))
- Registered constants are now required to have a valid identifier as name. ([#223](https://codeberg.org/NLnetLabs/roto/pulls/223))

#### New

- There is a new `Compiled::get_tests` method to get the tests in a Roto script
  without running them. This allows more flexibility in how the tests are run
  and what the output is. Thanks @algernon! ([#185](https://codeberg.org/NLnetLabs/roto/pulls/185))
- The `Runtime::add_io_functions` method adds a `print` method to the runtime,
  making it possible to write `"Hello, world!"` to the terminal! ([#193](https://codeberg.org/NLnetLabs/roto/pulls/193))
- `Runtime::compile` is a convenience function that will compile the script at
  the given path. It is no longer necessary to make a `FileTree` first. ([#193](https://codeberg.org/NLnetLabs/roto/pulls/193))

#### Bug fixes

- Fixed some cases where it was impossible to return certain types from
  registered functions. ([#210](https://codeberg.org/NLnetLabs/roto/pulls/210))

#### Other changes

- We switched from the `icu` crate to `unicode-ident` for the parsing of
  identifiers. This shrinks the dependency graph of `roto`. ([#173](https://codeberg.org/NLnetLabs/roto/pulls/173))
- We removed unnecessary files from the crate as published on <crates.io>.
  ([#174](https://codeberg.org/NLnetLabs/roto/pulls/174))
- `Runtime` has improved documentation that was previously on the non-public
  `runtime` module. ([#193](https://codeberg.org/NLnetLabs/roto/pulls/193))

## 0.6.0

Released 2025-06-10.

### Breaking changes

- The minimum supported Rust version is now 1.84.
- The `Compiled::get_function` method no longer takes separate type parameters
  for the parameter types and the return type, but a single function pointer
  type. ([#163](https://codeberg.org/NLnetLabs/roto/pulls/163))

```rust
// old
compiled.get_function::<Ctx, (bool, i32), Val<Verdict>>("main");

// new
compiled.get_function::<Ctx, fn(bool, i32) -> Val<Verdict>>("main");
```

- Registered functions no longer take arguments of runtime types by reference.
  Instead they take `Val<T>`, mirroring how they are passed in from Rust to Roto.
  ([#138](https://codeberg.org/NLnetLabs/roto/pulls/138))

```rust
// old
#[roto_function(runtime)]
fn foo(x: &Foo) -> Foo {
    todo!()
}

// new
#[roto_function(runtime)]
fn foo(x: Val<Foo>) -> Val<Foo> {
    todo!()
}
```

- The return type of registered functions now needs to implement the `Reflect`
  trait. ([#163](https://codeberg.org/NLnetLabs/roto/pulls/163))

### New

- Roto now features an assignment operator to update the value of a variable
  or a field. ([#158](https://codeberg.org/NLnetLabs/roto/pulls/158))
- The CLI now has a subcommand `print` to print out a Roto file with basic
  syntax highlighting. ([#139](https://codeberg.org/NLnetLabs/roto/pulls/139))
- The return type of registered functions can now be `Optional` or a `Verdict`.
  ([#163](https://codeberg.org/NLnetLabs/roto/pulls/163))
- The `FileSpec` type is now public in the `roto` crate. This allows users to
  set up their own systems for script discovery and easier testing. ([#151](https://codeberg.org/NLnetLabs/roto/pulls/151))
- Roto will now give better error messages when keywords are used as
  identifiers. ([#157](https://codeberg.org/NLnetLabs/roto/pulls/157))

### Bug fixes

- Fixed the implementation of the `==` and `!=` operators for `String`. ([#141](https://codeberg.org/NLnetLabs/roto/pulls/141))
- Fixed a couple of double frees and memory leaks. We now run the entire test
  suite under Valgrind to ensure that we will find these issues sooner.
  ([#147](https://codeberg.org/NLnetLabs/roto/pulls/147), [#149](https://codeberg.org/NLnetLabs/roto/pulls/149), [#158](https://codeberg.org/NLnetLabs/roto/pulls/158))
- Fixed an issue with the type inference of the return types of `filtermaps`.
  ([#152](https://codeberg.org/NLnetLabs/roto/pulls/152))

### Other changes

- Several outdated examples have been removed and examples of several errors
  have been updated. ([#164](https://codeberg.org/NLnetLabs/roto/pulls/164))
- We now do snapshot testing of error messages emitted by Roto. ([#165](https://codeberg.org/NLnetLabs/roto/pulls/165))

## 0.5.0

Released 2025-04-23.

### Breaking changes

- Renamed `Runtime::basic()` to `Runtime::new()`.
- Reading Roto scripts should now be done with a `FileTree` instead of
  `roto::read_files`.
- It is no longer necessary to pass the pointer size to Roto.
- The `roto_method`, `roto_static_method` & `roto_function` macros are more
  strict about the types they accept. Previously, some parameters could be
  marked as references where they should have been passed by value and vice
  versa, leading to incorrect behaviour.
- Hyphens are no longer allowed in identifiers (such as names of variables,
  functions, types and filtermaps).
- `filter-map` should now be written as `filtermap`
- Some outdated constructs were removed and are now treated as parse errors:
  `rib`, `table`, `output-stream`.

### New

- There is a full module system for Roto now, meaning that scripts can now be
  spread out over multiple files. More information can be found in the
  documentation.
- Optional types have been added. For any type `T` the type `T?` means an
  optional value of that type, similar to Rust's `Option<T>`. Values of that
  type can be constructed with `Optional.None` and `Optional.Some(v)`. It's
  also possible to match on optional values.

```roto
match optional_u32 {
  Some(x) -> x,
  None -> 0,
}
```

- Roto scripts can now contain tests. These are similar to filtermaps
  where `accept` means a passing test and `reject` a failing one.

```roto
test this_passes {
  accept
}

test this_fails {
  reject
}
```

- The `cli` function in the Roto API can be used to create a simple CLI for
  any runtime, allowing for easier debugging and testing of Roto scripts.
- The floating-point types `f32` and `f64` were added, including basic
  operators and some methods for floating point manipulation.

### Bug fixes

- There are several fixes for cloning and dropping of Rust values in Roto
  scripts. The implementation is much more sound now and should not lead to
  leakage and double frees anymore.
- Fixed an issue where one runtime methods would override another method causing
  the wrong method to be invoked by a script.
- Roto now uses a custom lexer instead of `logos` for more flexibility. This
  fixes some small issues around complex literals.

## 0.4.0

Released 2025-01-29.

### Breaking changes

- Filter maps no longer have a `define` and an `apply` block. `let` bindings
  should be used instead. For example:

```roto
# Roto 0.3
filter-map foo() {
    define {
        x = 4;
    }
    apply {
        accept x;
    }
}

# Roto 0.4
filter-map foo() {
    let x = 4;
    accept x;
}
```

### New

- Variables can now be created in more places with `let` bindings. `let`
  bindings replace the `define`/`apply` mechanism and are much more general
  because they can be used in any block. For example, inside functions or
  `if`-`else` blocks. The binding is scoped until the end of the block it is
  defined in. It is not allowed to declare multiple variables with the same
  name within a single block.
- The `String` type was added to represent pieces of text. String literals
  are enclosed in double quotes (`"`).
- It is now possible to declare constants in the runtime for a Roto script.
- Similarly, it is now possible to add "context" to Roto scripts. The variables
  in the context behave like constants, but they can differ between different
  calls to a script. In other words, constants are defined when the script is
  _compiled_, context is defined when the script is _run_.

### Bug fixes

- 64-bit numbers (i.e. `i64` and `u64`) were not type checked and compiled
  properly. They are now fixed.

## 0.3.0

Released 2024-11-21.

This is a completely rewritten version of Roto. The API and the language
itself are both completely different. See the API docs and the `examples/`
folder to see how to use it.

### Breaking changes

- There is no `VM` anymore.
- A script needs a `Runtime` with Rust objects to reference
- Many syntax changes to the Roto language.
- The `TypeValue` enum no longer exists, instead native Rust types are used
- No macros are used anymore for Roto types, they _can_ still be used for
  functions and methods, but they can also be added programmatically.
- As a corollary, the definitions for Roto types that are specific to
  Rotonda have moved to Rotonda.
- And more changes.

### New

- Types, functions and methods can be registered via `Runtime`.
- `Runtime::print_documentation` prints the documentation for all items
  registered in the Runtime.
- Roto is now compiled using cranelift and runs as native machine code.
- Parsing and type error messages have improved.


## 0.2.0

Released 2024-01-18.

First release.

Other changes

No changes compared to 0.1.0-rc0, but due to an error in the versioning of the
placeholder for this crate (0.1.0), we have to move to 0.2.0.

## 0.1.0-rc0

Released 2024-01-10.

First release candidate.
