-
-
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
Issues with invoking lib functions in other ways #311
Comments
Thanks for reporting! Code to reproduce: class A
def self.foo
end
end
lib B
fun foo : Int32
end
(A || B).foo What is your code doing? It's strange that you have a union of a lib type and a Crystal type. |
Hm, I think I was doing sth meaningless. I wanted to define a constant, whose value is computed via a libdSFMT function binding. Instead of putting the constant definition in the |
Hmm... do you have a small code to reproduce this issue? One way is the code I posted, but I'm not sure it's exactly the same issue. I checked out random.cr and ran the specs but they compile. How can I trigger the error? |
Hey @asterite, so here is what I did to trigger the issue (some pseudocode below, in an attempt to disentangle the issue from dsfmt and generalize):
Basically, we have a binding to a C function and then we use it inside libX to call that function and assign its returned value to the constant Sorry for the late reply, it is due to the difference in time between Argentina and UK :) |
Thanks! That's another way to reproduce the bug. I'll fix both of them... eventually. You should be able to do what you did there, to have a constant based on the return value of a function. A constant in Crystal means: once the value is set, it can't change. But it doesn't mean that the value must be known at compile time. So you can for example do: NOW = Time.now
puts NOW
puts NOW That's a perfectly valid constant, only it's not constant across different runs, but only in each run. No worries about the late reply, there's no need to hurry :-) |
Yes, I am following what you say. Great, I will change the code in random.cr later, when the bug is fixed in Crystal! |
Crystal says i've hit a bug and I should report it by opening an issue, so although I don't know what is the origin of the bug, here is the error message:
The text was updated successfully, but these errors were encountered: