Skip to content

Roc crashed: Color does not implement as_str #9123

@hubertmalkowski

Description

@hubertmalkowski
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({})
}

This program fails with

Roc crashed: Color does not implement as_str

When I move the Color type to seperate module (Color.roc) then it works fine.

Roc version

Roc compiler version debug-57f4ac5e

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions