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 wrapped interface values #1242

Merged
merged 3 commits into from
Sep 6, 2021

Conversation

nrwiersma
Copy link
Contributor

@nrwiersma nrwiersma commented Sep 2, 2021

This test (assert2.go) display 2 separate issues:

  1. assert2.go L28: Type assert tries to set an interface{} to a valueInterface. The typing here is complex, we have a valueT(strings.Builder) wrapped in a ptrT wrapped in a src iface wrapped in a valueT(interface{}). Type assert fails to realise that the valueT interface{} is wrapping the valueInterface.
  2. assert2.go L29: genValueBinMethodOnInterface does not try and get the bin method, as the typ.node (ptrT or a valueT(string.Builder)) is set. In this case the src iface is called with a receiver argument. To fix this the method is looked for first if possible, and only if not found does it fall back to the defaultGen.

Fixes #1227

Copy link

@jptosso jptosso left a comment

Choose a reason for hiding this comment

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

I tested the PR and it worked.

Copy link
Member

@mvertes mvertes left a comment

Choose a reason for hiding this comment

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

LGTM

@mvertes mvertes changed the title interp: handle valueT wrapped in a src iface wrapped in a valueT interface interp: improve handling of wrapped interface values Sep 6, 2021
@traefiker traefiker merged commit c33caeb into traefik:master Sep 6, 2021
@nrwiersma nrwiersma deleted the fix-1227 branch September 6, 2021 15:16
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 not being interpreted
4 participants