rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

better error message when the package refer its own namespace

Open popstarfreas opened this issue 4 years ago • 3 comments

Rescript Version: 9.1.3

When a file refers to the namespace of the project it is in certain conditions, it will cause an error on the first compile (or after rescript clean)

namespace: "Bug"

A.res

let fn = (x: Bug.B.t, _y: Bug.C.t): Bug.B.t => x

B.res

type t

C.res

type t

Produces error:

rescript: [8/10] src/A-Bug.cmj
FAILED: src/A-Bug.cmj

  We've found a bug for you!
  /root/rescript-bug/src/A.res:1:14-20

  1 _ let fn = (x: Bug.B.t, _y: Bug.C.t): Bug.B.t => x
  2 _

  The module Bug.B is an alias for module B-Bug, which is missing

rescript: [10/10] src/B-Bug.cmj
FAILED: cannot make progress due to previous errors.

or

rescript: [9/10] src/A-Bug.cmj
FAILED: src/A-Bug.cmj

  We've found a bug for you!
  /root/rescript-bug/src/A.res:1:27-33

  1 _ let fn = (x: Bug.B.t, _y: Bug.C.t): Bug.B.t => x
  2 _

  The module Bug.C is an alias for module C-Bug, which is missing

rescript: [10/10] src/C-Bug.cmj
FAILED: cannot make progress due to previous errors.

I can only get the error to show up once until I run rescript clean , then it will show up again. I don't know under what conditions it happens exactly, but I know that if I delete even a single one of the Bug. from A.res, it does not happen.

I only came across this because I generated an interface file and did not realize it had referenced the project's namespace, and I ran into this error.

popstarfreas avatar Jun 02 '21 09:06 popstarfreas

In general, it is not correct to refer its own namespace int the same project, we will see if we can detect this earlier

bobzhang avatar Jun 06 '21 13:06 bobzhang

Can confirm that this only sometimes causes a build failure, even when building in a sandboxed CI environment without cache, which makes it hard to discover. Maybe there is a race condition in the compiler that causes it to only sometimes fail?

Minnozz avatar Nov 30 '21 10:11 Minnozz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 13 '24 08:03 stale[bot]