Skip to content

Roc crashed: ... does not implement ... without type annotation #9244

@HajagosNorbert

Description

@HajagosNorbert

Source main.roc (same behavior with differently named file)

main! = |_args| {
  # uncommenting this line solves the crash
  # x : Dec
  x = 3
  _a = x.to_u64()
  Ok({})
}
$ roc version
Roc compiler version debug-e19771d2

$ uname -a
Linux desktop-nixos 6.18.15 #1-NixOS SMP PREEMPT_DYNAMIC Fri Feb 27 21:05:10 UTC 2026 x86_64 GNU/Linux

$ roc --no-cache repro.roc
Roc crashed: Builtin.Num.Dec does not implement to_u64

after uncommenting the type annotation:

$ roc repro.roc
-- MISSING METHOD --------------------------------

This to_u64 method is being called on a value whose type doesn't have that method:
   ┌─ /home/ez/code/examples-roc/examples/TowersOfHanoi/repro.roc:11:10
   │
11 │   _a = x.to_u64()
   │          ^^^^^^

The value's type, which does not have a method named to_u64, is:

    Dec

Hint: For this to work, the type would need to have a method named to_u64 associated with it in the type's declaration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions