roc-lang / roc

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

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

Closed BrianHicks closed 1 year ago

BrianHicks commented 2 years ago

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 commented 2 years ago

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

BrianHicks commented 2 years ago

further messing around:

ayazhafiz commented 2 years ago

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!