-
Notifications
You must be signed in to change notification settings - Fork 428
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
[Bug]: extern proc with varargs fails with non-literal param expression name #26759
Comments
It seems like a more accurate title would be to end with "non-literal param externName = "printf";
extern externName proc myprintf(arg);
myprintf("hello\n"); |
I've adjusted the title as suggested. I have a workaround I am using, as in my use case I know ahead of time how many args there will be, and so can constrain it This program works fine param n = 4;
param name = "printf";
extern name proc myprintf(arg...n);
myprintf("hello %f %f %f\n", 1.0, 2.0, 3.0); I believe this bug arises from a quirk of the old compiler. Literal expressions for the name are resolved at AST build time when converting the dyno uAST to the production compilers AST. Non-literal expressions can't be resolved then (get resolved during actual resolution), so we insert a dummy trailing formal called |
Does that suggest that once Dyno owns resolution, this should be resolved? And does it make you think we should wait for that to occur rather than trying to fix it on main? |
I strongly suspect that once dyno handles resolution this will just magically resolve. And because of that (and that for at least my specific case I have a workaround), I don't have a strong desire to try and fix it on main. I do think its a simple fix though, its just a matter changing how we thread the cname expr information to resolution to not abuse formal resolution. |
Extern procs allow renaming, so they can be linked against one name in C and used by another name in Chapel. Extern procs also support varargs. These are a really convenient features for generic programming with C libraries, but I've found a case the compiler does not handle well
This program works fine, extern proc with varargs
This program also works fine, extern proc with a renaming with varargs
This program fails to resolve
The text was updated successfully, but these errors were encountered: