Perform function declaration type check from the upper level scope (the scope where the function is declared), to avoid possible collisions of local variables with package names. Fixes #957.
21 lines
185 B
Go
21 lines
185 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
var t time.Time
|
|
|
|
func f() time.Time {
|
|
time := t
|
|
return time
|
|
}
|
|
|
|
func main() {
|
|
fmt.Println(f())
|
|
}
|
|
|
|
// Output:
|
|
// 0001-01-01 00:00:00 +0000 UTC
|