Stream: beginners

Topic: ✔ Calling method on constant


view this post on Zulip Jasper Woudenberg (Jun 23 2026 at 08:35):

Suppose I have this code:

# Html.roc
Html := { foo : U8 }.{
    href : Html, Str -> Html
    href = |html, _val| html

    a : Html
    a = { foo: 4 }
}

# main.roc
import Html
main! = |_args| {
    dbg Html.a.href("./other-page.html")
    Ok({})
}

This fails to compile:

-- DOES NOT EXIST --------------------------------

Html.href does not exist.

Html is in scope, but it has no associated href.

It's referenced here:
   ┌─ /tmp/nix-shell.aIXthY/roc/debug-no-git/SV2kioxYq85ztsnSm3L2FixYVOv0Bllr/main.roc:10:6
   │
10 │    dbg Html.a.href("./other-page.html")
   │       ^^^^^^^^^^^

Is this a bug? It works if I turn Html.a into a function that doesn't take any arguments so I can call Html.a().href(...).

view this post on Zulip Anton (Jun 23 2026 at 12:08):

I think it should work but I'm not 100% sure, what's your call @Richard Feldman

view this post on Zulip Richard Feldman (Jun 23 2026 at 12:13):

yeah that's a bug! Can you open a GH issue @Jasper Woudenberg?

view this post on Zulip Jasper Woudenberg (Jun 23 2026 at 12:14):

Done!
https://github.com/roc-lang/roc/issues/9773

view this post on Zulip Notification Bot (Jun 23 2026 at 12:14):

Jasper Woudenberg has marked this topic as resolved.


Last updated: Jul 23 2026 at 13:15 UTC