roc icon indicating copy to clipboard operation
roc copied to clipboard

stack overflow / bus error if there's an alias reference to a mutually recursive type

Open BrianHicks opened this issue 3 years ago • 3 comments

If you have this file:

platform "roc-lang/rbt"
    requires {} { init : Job }
    exposes []
    packages {}
    imports []
    provides [initForHost]

initForHost : Job
initForHost = init

Input : [FromProjectSource, FromJob Job]

Job : [Job { inputs : List Input }]

job : { inputs : List Input } -> Job
job = \config -> Job config

On running roc check, you'll get a stack overflow or a bus error (depending on build type.)

If you remove the Job member of the FromJob tag, or the type annotation for job, the error goes away. I guess FromProjectSource is not strictly required either (the error still happens without it) but I did all my testing with that in place so into the bug report it goes!

This is true as of da75f55aeacc18b452d3e359557599e1c1eca006, but I tested back to 3a12aa26ccb347a2374c01e960d37f77b8b3b8b0 and the bug is present.

BrianHicks avatar Sep 19 '22 22:09 BrianHicks

@ayazhafiz I feel like you might know right away what this could be—does it seem familiar?

BrianHicks avatar Sep 19 '22 22:09 BrianHicks

further messing around:

  • if you simplify to job : Input -> Job, you'll still get the stack overflow
  • if you simplify to job : Job -> Job, you won't

BrianHicks avatar Sep 19 '22 22:09 BrianHicks

I have a good idea of what it is, but how to resolve it has eluded us for a while. I think this may be the same as https://github.com/roc-lang/roc/issues/3216. I'll take a closer look tomorrow!

ayazhafiz avatar Sep 19 '22 22:09 ayazhafiz