Skip to content
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

interp: improve handling of empty interface values #1393

Merged
merged 2 commits into from
May 19, 2022

Conversation

mvertes
Copy link
Member

@mvertes mvertes commented May 3, 2022

At variable, function parameter, slice, map or field element assign,
if the destination type is an empty interface, the value was never
wrapped into a valueInterface (to preserve type mutability in case
of re-assign). Now we wrap it in a valueInterface if the source
type has a non empty set of methods, to allow a future use as a non
empty interface.

There are still corner cases, but it extends notably the support
of interfaces within the interpreter.

Fixes #1355.

At variable, function parameter, slice, map or field element assign,
if the destination type is an empty interface, the value was never
wrapped into a valueInterface (to preserve type mutability in case
of re-assign). Now we wrap it in a valueInterface if the source
type has a non empty set of methods, to allow a future use as a non
empty interface.

There are still corner cases, but it extends notably the support
of interfaces within the interpreter.

Fixes traefik#1355.
@mvertes mvertes added this to the v0.11.x milestone May 3, 2022
@mvertes mvertes requested a review from mpl May 3, 2022 11:27
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.

To make the tests pass, and fix #1355 , I think we only need the changes in call and in genDestValue. But should I trust you, and assume we need the other changes for later anyway?

@mvertes
Copy link
Member Author

mvertes commented May 19, 2022

Yes, the issue is testing only function call, but we have to cover consistently (at least for maintainability) the other possible cases where an interpreter non empty interface value can be assigned to an empty interface value. I agree that we may miss unit tests for those cases.

@mvertes mvertes merged commit d183f42 into traefik:master May 19, 2022
@mvertes mvertes deleted the fix-1355 branch May 19, 2022 15:54
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.

Interface with unexported method fails type assertion
3 participants