Stream: beginners

Topic: Duplicate Definitions: Scoping changes?


view this post on Zulip Simon Redding (Nov 17 2026 at 11:36):

Roc compiler version nightly-2026-11-15-f25da45

Hi All,
I've started getting "duplicate definition" compiler errors from code that compiled successfull with previous versions of the complier.
For example this snippet:

Html := {}.{
    Doc := {
        lang: Str ?? "en",
        head: Head,
        body: List(Block) ?? []
    }.{
        Head := { title: Str, css: List(Url) ?? []  }.{
            render : Head -> Str
            render = |h|
                "<head><meta charset=\"utf-8\"><title>${escape(h.title)}</title>${render_css_links(h.css)}</head>"
        }

        with_head : Head -> Doc
        with_head = |head|
            Doc.{ head }

        with_lang : Doc, Str -> Doc
        with_lang = |doc, lang| { ..doc, lang }

        with_body : Doc, List(Block) -> Doc
        with_body = |doc, body| { ..doc, body }

        render : Doc -> Str
        render = |doc|
            "<!DOCTYPE html>\n<html lang=\"${escape(doc.lang)}\">${doc.head.render()}${render_body(doc.body)}</html>"
    }
...

Now gives me:

── ● duplicate definition ──────────────────────────────────────────────────────────────── Html.roc:11:13

The name render is being redeclared here.

render = |h|
^^^^^^

In this scope, render was already defined in Html.roc:26:9.

render = |doc|
^^^^^^

Is this an intentional change or have I missed something?

view this post on Zulip Anton (Nov 17 2026 at 11:57):

Hi @Simon Redding,
That is indeed an intentional change, it was announced here.

view this post on Zulip Simon Redding (Nov 17 2026 at 12:01):

Thanks.
My bad.

view this post on Zulip Anton (Nov 17 2026 at 12:04):

No problem :)


Last updated: Nov 26 2026 at 20:35 UTC