Re: [go-nuts] variable set in a loop but unused not failing compilation

2024-05-06 Thread Tiago de Bem Natel de Moura
Hi Axel, Thanks for the explanation, it makes sense. Yes, I think it would be a good case for a `vet` warning. On Monday 6 May 2024 at 15:35:02 UTC+1 Axel Wagner wrote: > Hi, > > I'll note that this has nothing, really, to do with the loop, but with the > fact that you are assigning a struct f

Re: [go-nuts] variable set in a loop but unused not failing compilation

2024-05-06 Thread 'Axel Wagner' via golang-nuts
Hi, I'll note that this has nothing, really, to do with the loop, but with the fact that you are assigning a struct field. For a simpler example, compare this: https://go.dev/play/p/MmR-AhOUQH3 with this: https://go.dev/play/p/Y1uoI8thYuV If you only write to the entire variable, the compiler comp

[go-nuts] variable set in a loop but unused not failing compilation

2024-05-06 Thread Tiago de Bem Natel de Moura
Hello, We had the bug below in production: https://go.dev/play/p/-jewy7e7UcZ Look at the `opt` variable inside `listGithubPullReviews`, it's set multiple times (inside the loop) but never used... it was supposed to be passed as the last argument of `ListReviews()`. Why Go compiler is not givin