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

Compiler emits error "Violated assert: be_value->type->canonical == type" #1768

Closed
leon332157 opened this issue Jan 4, 2025 · 3 comments
Closed
Assignees
Labels
Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works

Comments

@leon332157
Copy link

While compiling my code I get this error emitted:

 The compiler encountered an unexpected error: "Violated assert: be_value->type->canonical == type".

- Function: llvm_emit_parameter(...)
- Source file: /home/leon3/.cache/yay/c3c-git/src/c3c/src/compiler/llvm_codegen_expr.c:5458

🙏 Please consider taking the time to file an issue on GitHub, so that we can get it fixed:

https://github.com/c3lang/c3c/issues/new so that we can get it fixed.

I have provided a minimal code sample that would trigger this issue:

extern fn CInt execvp(CChar* file, CChar*[] argv);

fn int main(String[] args)
{
    ZString[] argv = {"ls", "-l", "-a"};
    execvp((CChar*)"ls", (CChar*[])argv);
    return 0;
}
@lerno lerno self-assigned this Jan 4, 2025
@lerno lerno added Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works labels Jan 4, 2025
@lerno
Copy link
Collaborator

lerno commented Jan 4, 2025

This should work now.

@lerno
Copy link
Collaborator

lerno commented Jan 4, 2025

However, note that the code you probably want is:

extern fn CInt execvp(CChar* file, CChar** argv);

fn int main(String[] args)
{
    ZString[] argv = {"ls", "-l", "-a"};
    execvp((CChar*)"ls", (CChar**)argv);
    return 0;
}

Or even better, replace CChar* by ZString

extern fn CInt execvp(ZString file, ZString* argv);

fn int main(String[] args)
{
    ZString[] argv = {"ls", "-l", "-a"};
    execvp("ls", argv);
    return 0;
}

@leon332157
Copy link
Author

Tested working on latest commit

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