-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
splatting into variadic C function yields a BUG #15322
Comments
I suppose there are slight differences between variadic concepts, particularly the point of resolution: So the behaviour seems to be fine, just the error message needs to be improved. In some cases the error message for an invalid splat type is not a BUG error: foo *[1] # Error: argument to splat must be a tuple, not Array(Int32) |
Btw. I get a different error message than reported and this seems correct for the example code. The splatted type is
|
Ooops, there was a to_unsafe too much in the somewhat simplified example. I updated it. |
The failure is unrelated to C variadic functions: Crystal won't splat anything but a Tuple (length & types known at compile time). def foo(arg, *rest)
end
foo(*["a", "b", "c"])
Whereas AFAIK C behaves the same:
|
I'd like to point out:
|
Yes, the error message needs to be improved. I'm not quite sure why there are two different ones in the first place, or rather what's the difference between |
I guess it's resolving arguments in a |
Bug Report
Assuming the following definitions:
Calling
yields
When compiling.
I'd expect that to work, because the whole point of variadic functions is to be able to be called by a variable amount of arguments.
EDIT: Ok so perhaps it shouldn't work, due to general limitations of splatting arrays into functions, but it should probably not emit BUG.
Crystal 1.14.0 [dacd97b] (2024-10-09)
LLVM: 18.1.6
Default target: x86_64-unknown-linux-gnu
Linux 6.11.0-1007, Ubuntu
The text was updated successfully, but these errors were encountered: