-
Notifications
You must be signed in to change notification settings - Fork 362
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
stdlib._net_http_ResponseWriter is not seen as an http.Hijacker #1425
Comments
Another example, from the same root cause, but with a different impact, and in a different part of the stdlib.
|
Another different/interesting case:
this one is a little bit different, because the implemented interface is actually a non-exported one this time, in image/format.go:
which is used in e.g. As with the other cases above, the Go compiler sees the interface is being implemented, whereas Yaegi does not. Edit: I went through the rest of the image/* package, and I believe these are the other interfaces we'll have to address as well: in jpeg/writer.go and gif/writer.go , we have the exact counterpart of the reader case above, i.e.:
which is used when encoding images. On the other hand, we have specific interfaces used in png:
In theory, we need to take care of opaquer, because it is asserted when encoding from an image.Image passed as argument, as so:
but in practice it is unlikely to be a problem, since the image passed as argument is usually a concrete type coming from the stdlib (e.g. type RGBA) too, which itself implements the Opaque method. And it's more or less the same situation with:
|
This change implements a workaround to better support composed interfaces in yaegi and let the interpreter to define objects which impletment multiple interfaces at once. We use the existing MapTypes to store what possible composed interfaces wrapper could be used for some interfaces. When generating an interface wrapper, the wrapper with the highest number of implemented methods is chosen. This is still an imperfect solution but it improves the accuracy of interpreter in some critical cases. This workaround could be removed in future if/when golang/go#15924 is resolved. Fixes traefik#1425.
This change implements a workaround to better support composed interfaces in yaegi and let the interpreter define objects which implement multiple interfaces at once. We use the existing MapTypes to store what possible composed interface wrapper could be used for some interfaces. When generating an interface wrapper, the wrapper with the highest number of implemented methods is chosen. This is still an imperfect solution but it improves the accuracy of interpreter in some critical cases. This workaround could be removed in future if/when golang/go#15924 is resolved. Fixes #1425.
The following program
sample.go
triggers an unexpected resultExpected result
Got
Yaegi Version
cb642c4 (devel)
Additional Notes
Related traefik issue:
traefik/traefik#8682
The text was updated successfully, but these errors were encountered: