-
Notifications
You must be signed in to change notification settings - Fork 413
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
Missing error message when returning an inner function that uses an outer-local var #6538
Comments
While I agree this is something we should have a better error message for, whether or not you can do this at all is an open design question for Chapel first-class functions. If the inner function is returned, presumably you'd want the |
Attaching a piece of heap memory to a function pointer (isn't it what doing this is?) sounds like it might lead to some interesting idioms. But at the same time, I personally would find something like this a bit confusing (compared to functionality it brings) and avoid writing code like this as much as possible. |
My suggestion is something like C++11's lambdas. Capturing it by value if its like above ( Edit: Interestingly, if this idea was implemented, perhaps it could be applied to |
Add new error message future for issue #6538 [contributed by @e-kayrakli, reviewed by me] Adds a future for issue #6538 Added test is reported as future with standard linux64.
Without
With
They both seem to be the same issue. In both cases, the lambda is referencing a (different flavor of) outer-local var. |
@e-kayrakli, looks like #20991 resolved the future associated with this, I think we can close this? |
Looks right based on the fact that that PR retired the future associated with this issue. Thanks! |
Summary of Problem
Compiler should create an error message when the user's trying to return an inner function that uses local variables from it's parent function(s).
Current behavior is an internal error, that seems to be coming from a slightly irrelevant part of the compiler. Most likely it is due to a missing actual for an additional formal compiler creates in the inner function's signature to capture the outer variable.
Steps to Reproduce
Source Code:
Compile command:
chpl foo.chpl
Execution command:
Doesn't compile. (It shouldn't)
Associated Future Test(s):
PR: #6539
Adds
test/users/engin/retInnerFunction.chpl
Configuration Information
chpl --version
:$CHPL_HOME/util/printchplenv --anonymize
:gcc --version
orclang --version
:The text was updated successfully, but these errors were encountered: