c3c icon indicating copy to clipboard operation
c3c copied to clipboard

$exec fails to resolve constant in another module dependent on file order/names

Open Dodzey opened this issue 1 year ago • 4 comments

Consider an empty project created with c3c init, put 3 files in src folder - the names of which are significant for reproducing the issue:

foo.c3

module foo;

const EXEC_TOOL = "echo";

other.c3

module foo;

main.c3

module main;
import foo;

$exec(foo::EXEC_TOOL, "\"int x;\"");

fn void main() {}

This fails to compile with % c3c --trust=full build

 1: module main;
 2: import foo;
 3: 
 4: $exec(foo::EXEC_TOOL, "\"int x;\"");
               ^^^^^^^^^
(...../src/main.c3:4:12) Error: 'foo::EXEC_TOOL' could not be found, did you spell it right

If I rename other.c3 to foo2.c3 then it builds ok.

I would suspect this is due to some ordering of the files due to the names affecting the EXEC pass?

Dodzey avatar Aug 03 '24 19:08 Dodzey

Interestingly, c3c --trust=full compile src/*.c3 works! echo src/*.c3 is, as you would expect src/foo.c3 src/main.c3 src/other.c3

Dodzey avatar Aug 03 '24 19:08 Dodzey

However, c3c --trust=full compile src/main.c3 src/foo.c3 src/other.c3 fails

Dodzey avatar Aug 03 '24 19:08 Dodzey

Yes, this is a problem with evaluation order. I will have a look at it.

lerno avatar Aug 05 '24 09:08 lerno

This should now work correctly.

lerno avatar Aug 13 '24 20:08 lerno

Confirmed - works

Dodzey avatar Sep 01 '24 21:09 Dodzey