oridb / mc

Myrddin Compiler
MIT License
387 stars 34 forks source link

Calling a generic function in an impl definition crashes the compiler #207

Open typeless opened 2 years ago

typeless commented 2 years ago

This seems to happen only when the caller of the trait, the trait definition and the impl definition are all in different modules.

Here is a repro https://github.com/typeless/myr-bug/blob/main/c.myr#L12

$ mbld
        6m -O obj -I obj -I obj a.myr
Missing decl f
CRASH: 6m -O obj -I obj -I obj a.myr
typeless commented 2 years ago

Update: My description of the issue was inaccurate. It seems to be that

  1. A pkg A makes calls to a generic function g defined in pkg B. The generic function g makes calls to a internal function f defined in the same pkg B.
  2. When the generic function g is imported into the pkg A, it's expanded in the pkg A. But in the instantiated g in A, it cannot see the function f defined internally in B.