Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Dodzey opened this issue Aug 3, 2024 · 5 comments
Closed
Assignees
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works

Comments

@Dodzey
Copy link
Contributor

Dodzey commented Aug 3, 2024

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
Copy link
Contributor Author

Dodzey commented Aug 3, 2024

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
Copy link
Contributor Author

Dodzey commented Aug 3, 2024

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

@lerno lerno added the Bug Something isn't working label Aug 3, 2024
@lerno
Copy link
Collaborator

lerno commented Aug 5, 2024

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

@lerno lerno self-assigned this Aug 13, 2024
@lerno lerno added the Fixed Needs Verification Fixed, but needs verification that it works label Aug 13, 2024
@lerno
Copy link
Collaborator

lerno commented Aug 13, 2024

This should now work correctly.

@Dodzey
Copy link
Contributor Author

Dodzey commented Sep 1, 2024

Confirmed - works

@Dodzey Dodzey closed this as completed Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works
Projects
None yet
Development

No branches or pull requests

2 participants