-
Notifications
You must be signed in to change notification settings - Fork 240
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
Function struct fields aren't callable. #1379
Comments
Yep, currently only variables with a function type are callable (plus actual declared functions). Regarding the reference one, that's most likely a bug in the lifetime analysis (unless there's something happening that I'm not seeing) |
fahrradflucht
added a commit
to fahrradflucht/jakt
that referenced
this issue
Feb 19, 2023
Allow creating local references to struct fields in methods. It turned out the way we were checking scope lifetimes was a bit backwards. We use this method every to guard against the inverse (the child scope outliving the parent) but the method wasn't implemented that way. To be honest I still don't understand a 100% why some tests were passing in the old implementation. We I also had to invert the exit condition to account for the fact that comptime scope parent chains are disjunct from runtime scope parent chains, but at least we now know that the json parser sample is testing for that case 😉. Fixing this also surfaced that the `stores_arguments` attribute test wasn't actually testing the feature but was passing due to the bug. I had to adjust it to actually test the failure case for it to continue to pass. Progress on SerenityOS#1379.
fahrradflucht
added a commit
to fahrradflucht/jakt
that referenced
this issue
Feb 19, 2023
Allow creating local references to struct fields in methods. It turned out the way we were checking scope lifetimes was a bit backwards. We use this method every to guard against the inverse (the child scope outliving the parent) but the method wasn't implemented that way. To be honest I still don't understand a 100% why some tests were passing in the old implementation. We I also had to invert the exit condition to account for the fact that comptime scope parent chains are disjunct from runtime scope parent chains, but at least we now know that the json parser sample is testing for that case 😉. Fixing this also surfaced that the `stores_arguments` attribute test wasn't actually testing the feature but was passing due to the bug. I had to adjust it to actually test the failure case for it to continue to pass. Progress on SerenityOS#1379.
fahrradflucht
added a commit
to fahrradflucht/jakt
that referenced
this issue
Feb 19, 2023
Allow creating local references to struct fields in methods. It turned out the way we were checking scope lifetimes was a bit backwards. We use this method every to guard against the inverse (the child scope outliving the parent) but the method wasn't implemented that way. To be honest I still don't understand a 100% why some tests were passing in the old implementation. We I also had to invert the exit condition to account for the fact that comptime scope parent chains are disjunct from runtime scope parent chains, but at least we now know that the json parser sample is testing for that case 😉. Fixing this also surfaced that the `stores_arguments` attribute test wasn't actually testing the feature but was passing due to the bug. I had to adjust it to actually test the failure case for it to continue to pass. Progress on SerenityOS#1379.
alimpfard
pushed a commit
that referenced
this issue
Feb 20, 2023
Allow creating local references to struct fields in methods. It turned out the way we were checking scope lifetimes was a bit backwards. We use this method every to guard against the inverse (the child scope outliving the parent) but the method wasn't implemented that way. To be honest I still don't understand a 100% why some tests were passing in the old implementation. We I also had to invert the exit condition to account for the fact that comptime scope parent chains are disjunct from runtime scope parent chains, but at least we now know that the json parser sample is testing for that case 😉. Fixing this also surfaced that the `stores_arguments` attribute test wasn't actually testing the feature but was passing due to the bug. I had to adjust it to actually test the failure case for it to continue to pass. Progress on #1379.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Either I'm holding something wrong or function fields aren't callable at the moment.
Problem
This test will fail to compile even though I would assume it should:
Jakt error:
Investigations
Copying the callback to a temp var
I tried assigning the function as a temp var first. This will codegen, but the resulting cpp won't compile.
C++ Error:
Makes sense to me that the function isn't copyable, but probably this should fail earlier? 🤔
Using a pointer indirection
Avoiding copying by using a pointer will work for outside property access.
However, it won't work for the method access case because the compiler thinks the reference is outlived (is that right? 🤔):
Jakt error:
The text was updated successfully, but these errors were encountered: