roc-lang / roc

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

reached an unreachable in compiler/mono/src/borrow.rs #1844

Open BrianHicks opened 3 years ago

BrianHicks commented 3 years ago

As of this commit: https://github.com/rtfeldman/rbt/pull/15/commits/c040ceb2fd373e7db6fcdf832981a5ee2ff64dfb, the compile fails with an unreachable error message:

rbt » ./roc examples/webassembly/rbt.roc
thread 'main' panicked at 'internal error: entered unreachable code: symbol/layout `pf.Rbt.job` ProcLayout { arguments: [Struct([Struct([Builtin(List(Builtin(Str))), Builtin(Str)]), Builtin(List(Builtin(Str)))])], result: Union(NonNullableUnwrapped([Struct([Struct([Builtin(List(Builtin(Str))), Builtin(Str)]), Builtin(List(Builtin(Str))), Builtin(List(RecursivePointer)), Builtin(List(Builtin(Str)))])])) } combo must be in DeclarationToIndex', compiler/mono/src/borrow.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm trying (and currently failing) to find the minimal set of changes that will either reproduce this problem or get around it, and will update when/if I find something smaller. That said, I've been able to get a smaller version of examples/webassembly/rbt.roc.

This passes the type checker and gets sent to the platform:

app "build"
    packages { pf: "../.." }
    imports [ pf.Rbt.{ Rbt, Tool, tool, systemTool, Job, job, exec } ]
    provides [ init ] to pf

# todo: bikeshed "init" name more
init : Rbt
init =
    Rbt.init { default: bundle2 }

bundle2 : Job
bundle2 =
    job {
        command: exec (systemTool "bash") [ "c", "touch out" ],
        outputs: [ "out" ],
    }

this doesn't:

app "build"
    packages { pf: "../.." }
    imports [ pf.Rbt.{ Rbt, Tool, tool, systemTool, Job, job, exec } ]
    provides [ init ] to pf

# todo: bikeshed "init" name more
init : Rbt
init =
    Rbt.init { default: bundle2 }

bundle2 : Job
bundle2 =
    job {
        command: exec (systemTool "bash") [ "c", "touch out" ],
        inputs: [ otherFile ],
        outputs: [ "out" ],
    }

otherFile : Job
otherFile =
    job {
        command: exec (systemTool "bash") [ "c", "touch out" ],
        outputs: [ "out" ],
    }
BrianHicks commented 3 years ago

in the process of trying to get a SSCCE I found a workaround: if all the fields in the record are required, this error doesn't happen