Proposal Details
A unary min and max call is an identity function and its presence suggests a bug.
I had code that was doing the following:
blockSize = min(max(r.minBlockSize, blockSize, r.maxBlockSize))
where the intent is to clamp blockSize within a certain range.
However, due to a single misplaced ), this does not work.
It should have been:
blockSize = min(max(r.minBlockSize, blockSize), r.maxBlockSize)
I propose that go vet flag any unary calls to min or max, which would have caught my bug where I had 3 arguments passed to max, but only 1 argument passed to min.
Proposal Details
A unary
minandmaxcall is an identity function and its presence suggests a bug.I had code that was doing the following:
where the intent is to clamp
blockSizewithin a certain range.However, due to a single misplaced
), this does not work.It should have been:
I propose that
go vetflag any unary calls tominormax, which would have caught my bug where I had 3 arguments passed tomax, but only 1 argument passed tomin.