-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly return constant expressions in functions
In the case of a function returning a single value, a constant result could be ignored, and the function would return a zero value. Fixes #889.
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
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,17 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
func get10Hours() time.Duration { | ||
return 10 * time.Hour | ||
} | ||
|
||
func main() { | ||
fmt.Println(get10Hours().String()) | ||
} | ||
|
||
// Output: | ||
// 10h0m0s |
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