Skip to content

interp: improve handling of empty interface values#1393

Merged
mvertes merged 2 commits into
traefik:masterfrom
mvertes:fix-1355
May 19, 2022
Merged

interp: improve handling of empty interface values#1393
mvertes merged 2 commits into
traefik:masterfrom
mvertes:fix-1355

Conversation

@mvertes

@mvertes mvertes commented May 3, 2022

Copy link
Copy Markdown
Collaborator

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

@mpl mpl left a comment

Copy link
Copy Markdown
Collaborator

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

mvertes commented May 19, 2022

Copy link
Copy Markdown
Collaborator Author

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