-
Notifications
You must be signed in to change notification settings - Fork 64
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
Support multiple return values #1089
Comments
The expressions supporting multiple values will model the targets with lists. Tasks:
Tricky problems:
Discussed solutions:
|
If we treat multiple return values as a container, we could add an implicit "unpack" node in situations where the return values are unpacked to separate values. |
After some more internal discussion, we arrived at the following proposal: We introduce a new i, err = func() .We remove the var i = 1 effectively will be modelled as var i int
i = 1 If a language supports mixed assignment and declarations (e.g. Go in the following snippet), we extract all possible declarations out of the assignment and model them as implicit // This declares i, but assigns err
var err error
i, err := ret() which is then equivalent to var err error
var i any
i, err = ret() |
@maximiliankaul Is this issue still relevant? I think we implemented this in python using our assign expression? Or at least it should be done once #1729 is merged. |
I think it's no longer relevant. I'll double check that we have tests for all the corner cases discussed above and then close this issue asap. |
There are still some bugs. See #1807 for fixes. |
The CPG should support multiple return values per statement. This is useful for language constructs like
a, b = (1, 2)
orvalue, error := someFunction()
.Note, that such constructs can also happen in unexpected places like loops
for a, b, c in ...
where we would have three loop variables in this example.Tasks
AssignExpression
in all frontends #1260The text was updated successfully, but these errors were encountered: