FWIW, I’m not sure that I think it is the best outcome. If the expression is a constant the loop can be omitted entirely - which I would hope the compiler would do. And consequently the errors from the compiler should reflect that - including the inverse if the expression is true.
> On Oct 11, 2024, at 11:16 PM, Pierpaolo Bernardi <olopie...@gmail.com> wrote: > > On Sat, Oct 12, 2024 at 5:35 AM Cleberson Pedreira Pauluci > <pauluci.cleber...@gmail.com> wrote: >> >> I agree with @robert. >> The compiler cannot guarantee that the function will always return a value. >> Even though we can see that the loop will eventually return i value, the >> compiler isn't able to make this determination statically. > > Yes, now I get it. Thank you all for the help. > > Cheers > > -- > 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/CANY8u7HOn6o557cX6Es19EX_eEi7qXBh2zECwu_jQCqhEz4atg%40mail.gmail.com. -- 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/A9868778-43DD-467E-AAAF-D39B30EEDE16%40ix.netcom.com.