Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mvertes
Copy link
Collaborator

@mvertes mvertes commented Mar 22, 2023

In the case of a Go short definition (i.e. a, b := f()), the new defined variables must be (re-)created in order to preserve the previous value (if in a loop) which can be still in use in the context of a closure. This must not apply to redeclared variables which simply see their value reassigned.

The problem was both occuring in callBin() for runtime functions and assignFromCall() for functions created in the interpreter.

Fixes #1497.

In the case of a Go short definition (i.e. `a, b := f()`), the
new defined variables must be (re-)created in order to preserve the
previous value (if in a loop) which can be still in use in the
context of a closure. This must not apply to redeclared variables
which simply see their value reassigned.

The problem was both occuring in callBin() for runtime functions
and assignFromCall() for functions created in the interpreter.

Fixes traefik#1497.
@mvertes mvertes added this to the v0.15.x milestone Mar 22, 2023
@mvertes mvertes requested a review from mpl March 22, 2023 10:01
Copy link
Collaborator

@mpl mpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after last typo fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

double assignment + closure, in a for loop, reuses the same variable, instead of assigning to a new one.

3 participants