Skip to content

Commit

Permalink
fix: automatic type conversion when returning untyped value
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes authored and traefiker committed Nov 19, 2019
1 parent 56bec97 commit 9f1f312
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions _test/ret7.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

func one() uint {
return 1
}
func main() {
println(one())
}

// Output:
// 1
6 changes: 5 additions & 1 deletion interp/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,11 @@ func _return(n *node) {
case interfaceT:
values[i] = genValueInterface(c)
default:
values[i] = genValue(c)
if c.typ.untyped {
values[i] = genValueAs(c, def.typ.ret[i].TypeOf())
} else {
values[i] = genValue(c)
}
}
}

Expand Down

0 comments on commit 9f1f312

Please sign in to comment.