$exec fails to resolve constant in another module dependent on file order/names
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?
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
However, c3c --trust=full compile src/main.c3 src/foo.c3 src/other.c3 fails
Yes, this is a problem with evaluation order. I will have a look at it.
This should now work correctly.
Confirmed - works