Stream: compiler development

Topic: bug: Outstanding references to the derived module


view this post on Zulip Luke Boswell (Dec 29 2024 at 01:23):

Does this look like something easy to fix? https://github.com/roc-lang/roc/issues/7429

It's giving me grief upgrading the webserver demo's and using Isaac's RTL templating engine

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:26):

I didn't repro with latest nightly

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:26):

What version of Roc are you using?

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:28):

Built from source

$ roc version
roc built from commit 06e78daa91, committed at 2024-12-28 22:05:45 UTC

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:29):

oh wait, let me update the Issue, it needs to be in a sub-folder

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:30):

Like

$ roc check src/Views/broken.roc
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
Outstanding references to the derived module
Location: crates/compiler/load_internal/src/file.rs:3358:29

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:31):

Sorry, I hadn't realised the folder thing was relevant here

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:38):

The whole derived_module thing looks a bit confusing.

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:45):

I'm unable to replicate

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:46):

I checked out the commit, created a --release build, and ran roc/target/release/roc check src/Views/broken.roc

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:46):

~/dev
❯ roc/target/release/roc check src/Views/broken.roc
0 errors and 0 warnings found in 29 ms.

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:47):

Is this in the roc-htmx-tailwind repo?

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:47):

Oh, that repo

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:48):

https://github.com/lukewilliamboswell/roc-htmx-tailwindcss-demo/tree/upgrade-0.11.0

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:49):

Yeah, if you checkout that branch and add the file src/Views/broken.roc you should get;

$ roc check src/Views/broken.roc
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
Outstanding references to the derived module
Location: crates/compiler/load_internal/src/file.rs:3358:29

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:49):

It also happens with $ roc check src/Views/Pages.roc but the broken.roc is a super small repro

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:49):

Okay, got it with Layout.roc

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:51):

Well, it also works with just module [] in broken.roc

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:52):

ohk, interesting

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:52):

So this isn't a "minimal" repro IMO since I think the problem is elsewhere

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:56):

Ok heres a minimal repro https://github.com/lukewilliamboswell/roc-htmx-tailwindcss-demo/tree/broken

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:56):

There's only two files in there, the broken.roc and a minimal main.roc referencing the new webserver

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:57):

Okay, that's minimal

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:57):

I wonder if it happens with basic-cli

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:57):

1 sec

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:59):

Yeah it does. Just pushed a commit changing the main.roc to

app [main!] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.17.0/lZFLstMUCUvd5bjnnpYromZJXkQUrdhbva4xdBInicE.tar.br" }

main! = \_ -> Err TODO

view this post on Zulip Sam Mohr (Dec 29 2024 at 01:59):

Okay, then it's maybe not a platform problem?

view this post on Zulip Luke Boswell (Dec 29 2024 at 01:59):

No it's definitely the compiler

view this post on Zulip Sam Mohr (Dec 29 2024 at 02:00):

Oh, it's definitely the compiler

view this post on Zulip Sam Mohr (Dec 29 2024 at 02:00):

I mean whether this happens in just a Roc package vs. a platform

view this post on Zulip Luke Boswell (Dec 29 2024 at 02:02):

In this case it's neither of those... this has an app module at the root, the parent folder from the module we are checking

view this post on Zulip Sam Mohr (Dec 29 2024 at 02:24):

Can you update the GH issue?

view this post on Zulip Luke Boswell (Dec 29 2024 at 02:37):

done

view this post on Zulip Anthony Bullard (Dec 29 2024 at 03:04):

That’s weird. Can you check the compiler commit right before my change to package headers?

view this post on Zulip Anthony Bullard (Dec 29 2024 at 03:04):

If that works it’s an easy bisect :blush:

view this post on Zulip Anthony Bullard (Dec 29 2024 at 03:05):

And you get the added pleasure of shaming me

view this post on Zulip Ayaz Hafiz (Dec 29 2024 at 03:30):

the bug is present before that

view this post on Zulip Notification Bot (Dec 29 2024 at 03:33):

37 messages were moved here from #compiler development > casual conversation by Luke Boswell.

view this post on Zulip Ayaz Hafiz (Dec 29 2024 at 03:55):

is this a valid way to use a value from a platform?

module []

import pf.Stderr

foo = Stderr.line

view this post on Zulip Ayaz Hafiz (Dec 29 2024 at 04:46):

i understand the problem well I think. The issue is that when a module is checked, if there is a transitive platform found, that platform is also placed into the queue of modules to resolve (https://github.com/roc-lang/roc/blob/723e35f11e1b1744c77cde77e42ed2b48fff12a6/crates/compiler/load_internal/src/file.rs#L1300-L1361). However if the module doesn't use the platform, it will finish all its computation before the platform has had a chance to, hence the panic. I think probably (?) the right way to do this is to only traverse to find the package if it doesn't exist in the package shorthand list, and then add it as a dependency of the module, but I don't totally understand all the flow here and Ive run out of tie


Last updated: Jul 06 2025 at 12:14 UTC