You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is backwards. We should generate the first nil check and remove the second one, on pain of panicking on the wrong line.
I'm not sure whether this impacts any code in practice right now. Obvious reproducers like the one above already have their duplicate nil checks removed by the early nilcheck pass. I noticed it when implementing the TODO at the end of nilcheck2 caused the wrong nil checks to be eliminated from test/nilptr3.go.
Oh, step 1 seems to require modifying the compiler, though I wasn't able to immediately figure out how to do that.
Either way, code at tip seems to be working correctly, so I'm bumping this to 1.11. I'll leave to @josharian and @randall77 to decide whether this is still worth pursuing.
Reproduce:
go tool compile -d=nil x.go
this code:Result:
This is backwards. We should generate the first nil check and remove the second one, on pain of panicking on the wrong line.
I'm not sure whether this impacts any code in practice right now. Obvious reproducers like the one above already have their duplicate nil checks removed by the early nilcheck pass. I noticed it when implementing the TODO at the end of nilcheck2 caused the wrong nil checks to be eliminated from test/nilptr3.go.
Opinions about the correct fix are welcome.
cc @randall77
The text was updated successfully, but these errors were encountered: