When I define an ADT in app module like this:
app [main!] {pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst"}
import pf.Stdout
Color := [Red, Green, Blue].{
as_str : Color -> Str
as_str = |color| match color {
Red => "Red"
Green => "Green"
Blue => "Blue"
}
}
main! = |_args| {
red : Color
red = Red
Stdout.line!("My favourite color is ${red.as_str()}")
Ok({})
}
I get this error when I try to run it (it compiles - this runtime error):
Roc crashed: Color does not implement as_str
However when I move Color definition to seperate Color.roc file then everything works.
Is this intended behavior? Do member methods only work when a type is imported from an external module, or am I missing some syntax requirement for local type definitions?
It should work, so a bug I think.
Ok, then I'll report it on github :)
https://github.com/roc-lang/roc/issues/9123
Last updated: Feb 20 2026 at 12:27 UTC