mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
ir: fix interface call edge case
A function on a type that is put in an interface must not be assumed to not need a context pointer when it isn't directly put in a function pointer, because the interface call side won't know this and pass an extra parameter with that extra function pointer. This is usually not a problem but WebAssembly has strict checks on function signatures so this resulted in an error when running src/examples/test/test.go.
This commit is contained in:
@@ -416,6 +416,12 @@ func (p *Program) AllInterfaces() []*Interface {
|
|||||||
|
|
||||||
func (p *Program) FunctionNeedsContext(f *Function) bool {
|
func (p *Program) FunctionNeedsContext(f *Function) bool {
|
||||||
if !f.addressTaken {
|
if !f.addressTaken {
|
||||||
|
if f.Signature.Recv() != nil {
|
||||||
|
_, hasInterfaceConversion := p.TypeNum(f.Signature.Recv().Type())
|
||||||
|
if hasInterfaceConversion && p.SignatureNeedsContext(f.Signature) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return p.SignatureNeedsContext(f.Signature)
|
return p.SignatureNeedsContext(f.Signature)
|
||||||
|
|||||||
Reference in New Issue
Block a user