Stream: bugs

Topic: Roc crashed: Builtin.U8 does not implement len()


view this post on Zulip Lukas Juhrich (Feb 20 2026 at 08:41):

Hi,

I've encountered the following behavior, and before opening an issue I would like to learn what I can do to debug this issue myself.

Context: in this (already somewhat condensed to the bug) snippet,

app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst" }

import pf.Stdout
print = Stdout.line!
main! = |_| {
  testVal = \\if(equals(1, 333), {ref}, "nothing")
  testVal->tokenize->Str.inspect->print

  Ok({})
}

tokenize: Str => Try([Eof, LParen, RParen, StringLit], [UnexpectedToken({message: Str})])
tokenize = |str| {
  bytes = str.to_utf8()
  if bytes.is_empty() {
    return Ok(Eof())
  }
  # bad region wtih type inference side effects for `bytes`
  _first_byte = match bytes.first() {
    Err(ListWasEmpty) => {return Ok(Eof())}
    Ok(b) => b
  }
  # /bad region
  _ascii_bytes = bytes->take_while(|_| True)
  Err(UnexpectedToken({message: "unexpected token"}))
}

take_while: List(a), (a -> Bool) => List(a)
take_while = |list, predicate| {
  var $new = List.with_capacity(list.len())
  for item in list {
    if !predicate(item) {
      return $new
    }
    $new = $new.append(item)
  }
  $new
}

I get no errors on roc check, but executing it yields

Roc crashed: Builtin.Num.U8 does not implement len

However, when I comment out the match (“bad region”), I get the expected output

Try.Err(UnexpectedToken({ message: "unexpected token" }))

Now how would I go about debugging this? Or: how do you do it? I could think of:

…nothing of which seems really feasible.
Thank you in advance :)

view this post on Zulip Anton (Feb 20 2026 at 09:26):

Hi @Lukas Juhrich,
Based on my first impression I believe this is a bug that AI can handle, I use claude code with opus 4.6 thinking set to high. I recommend running zig build minici to run all tests after the fix is done. The difficult part lies in assessing the quality of the fix. You can check who wrote the code that surrounds the fix and ask them to review it.

view this post on Zulip Lukas Juhrich (Feb 20 2026 at 09:55):

Hi and thanks for the quick reply,

Anton said:

Based on my first impression I believe this is a bug that AI can handle,

That would be nice if all I was interested in is a fix, but I would specifically like to do things myself to learn about the compiler. So if we pretend that this fix would be too difficult for AI – what would the strategy then be? Reading the code and tests to understand the pipeline, working test-driven and mainly working with zig build minici?

view this post on Zulip Anton (Feb 20 2026 at 10:08):

So if we pretend that this fix would be too difficult for AI

I think in this case we either pass the bug on to whomever has the most expertise with that part of the code or ask that person some questions and ask them to review the PR. My belief is that there is no generally applicable strategy in that case, you need to have a deep understanding of how things fit together, what the intended functionality is, and all the trade-offs involved.


Last updated: Feb 20 2026 at 12:27 UTC