-
Notifications
You must be signed in to change notification settings - Fork 53
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
casting? and "attempt to call value of type '((void) -> (any*) | nil)'" #12
Comments
I think part of the problem is that the value load returns might be nil. If that's the case, then you can't call it. You probably need to check that its type or value is not nil before calling it, but I'm not sure how that is done in typed lua. The example here might be relevant: You should be able to do this: Does that work? |
Thanks for the reply Kevin. It is perfect. |
okay thanks. turns out this wasn't how to replicate my original issue. Not sure if I should open a new issue, I'll try and ask here. As interface timetable
year: number
month: number
day: number
hour: number
min: number
sec: number
yday: number
wday: number
unpack: (self) -> (number, number, number, number, number, number)
normalise: (self) -> (self)
timestamp: (self) -> (number)
rfc_3339: (self) -> (string)
strftime: (self, string) -> (string)
end
new: (number, number, number, number, number, number) -> (timetable)
new_from_timestamp: (number) -> (timetable)
cast: (any) -> (timetable) local t:timetable = require"luatz.timetable".new_from_timestamp(123);
print(t:unpack()) I get the error:
|
I just pushed a commit that should fix this problem. Can you please pull it and test if it works? |
Looks like that fixed it! |
Cool! Thanks for the report. |
btw; is that the correct way to define a 'class'? the first items listed are actual contents; the later items are methods attached via And complete off topic now: do |
No, there is still not way to require/import other definitions inside Chapter 3 of my WIP PhD thesis includes a section about Object-Oriented programming with Typed Lua. |
Thanks! |
Is this still the case? Want me to open a new issue? |
Yes, this is still the case and please open an issue for this. Thanks! |
Trying to run:
Gives errors:
FWIW, I got this while trying to reproduce a different error as a test case.
The text was updated successfully, but these errors were encountered: