Skip to content

Commit

Permalink
interp: avoid collision between type and variable names in assign
Browse files Browse the repository at this point in the history
Fixes #1306
  • Loading branch information
mvertes authored Nov 9, 2021
1 parent cb81fe4 commit 348e713
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions _test/issue-1306.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import "fmt"

func check() (result bool, err error) {
return true, nil
}

func main() {
result, error := check()
fmt.Println(result, error)
}

// Output:
// true <nil>
2 changes: 1 addition & 1 deletion interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2013,7 +2013,7 @@ func compDefineX(sc *scope, n *node) error {
} else {
types = funtype.ret
}
if n.child[l-1].isType(sc) {
if n.anc.kind == varDecl && n.child[l-1].isType(sc) {
l--
}
if len(types) != l {
Expand Down

0 comments on commit 348e713

Please sign in to comment.