The Go compiler (I'm using go1.16 linux/amd64) correctly infers that function with an infinite for { … } loop that conditionally returns a value from within the loop does not also need to return a value at the end of the function:
- https://play.golang.org/p/07ZjFx2uJlx However, changing that infinite loop to a three-clause for loop with true as the continuation condition (e.g., for i := 0; true; i++ { … }) complains about a missing return at end of function: - https://play.golang.org/p/yf4ihkdBUXZ Shouldn't the compiler treat those two cases the same? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/be12d501-8ab7-4057-9529-76f420de345cn%40googlegroups.com.