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 giving an error for this case? AFAICS all of those 
`opt.Page = resp.NextPage` inside the loop cannot make any side effects, 
then it looks safe to assume the variable is only set and never used?

So, simplifying the problem, this is the non-failing 
case: https://go.dev/play/p/FLAIlVx_sSG

But if you change from a struct to a plain int, then the compiler gives: 
`./prog.go:6:2: 
a declared and not used`

Luckily, we were using a `ctx` with timeout otherwise it would be an 
infinite loop. The thing was tested but only for cases where all results 
came in a single page, then the loop aborted in the first iteration. I 
think this could be detected by the compiler, no?

-- 
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/9a2b5179-f083-4365-b0c6-e876f3fe6950n%40googlegroups.com.

Reply via email to