-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: fix receiver for exported method objects
When a function variable is assigned from an exported method, make sure the receiver is updated from the coresponding symbol. Fixes #1182.
- Loading branch information
Showing
4 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package d1 | ||
|
||
type T struct { | ||
Name string | ||
} | ||
|
||
func (t *T) F() { println(t.Name) } | ||
|
||
func NewT(s string) *T { return &T{s} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package d2 | ||
|
||
import "github.com/traefik/yaegi/_test/d1" | ||
|
||
var ( | ||
X = d1.NewT("test") | ||
F = X.F | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package main | ||
|
||
import "github.com/traefik/yaegi/_test/d2" | ||
|
||
func main() { | ||
f := d2.F | ||
f() | ||
} | ||
|
||
// Output: | ||
// test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters