roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.4k stars 309 forks source link

Monomorphization panic when giving a host a thunk #2412

Closed rtfeldman closed 2 years ago

rtfeldman commented 2 years ago

To reproduce:

  1. Start with examples/hello-world/Hello.roc
  2. In Package-Config.roc, change { main : Str } to { main : {} -> Str }
  3. In Hello.roc, change main = "Hello, World!\n" to main = \{} -> "Hello, World!\n"

This panics with '#UserApp.0 should be in the list of imported_module_thunks', compiler/mono/src/ir.rs:7143:13

ayazhafiz commented 2 years ago

I can't reproduce this on trunk anymore - can you? Interestingly though, running roc check (with a debug build) sometimes gives a panic:

thread 'main' panicked at 'assertion failed: state.dependencies.solved_all()', compiler/load/src/file.rs:1968:17

So I guess there's a race condition somewhere there

folkertdev commented 2 years ago

Richard and I discussed this earlier today (I also ran into the problem). The cause is the Effect module which is not imported by any module, but it is still scheduled for type checking. That never happens. We decided to go ahead with implementing https://github.com/rtfeldman/roc/issues/2405 and then the issue should disappear