Skip to content

Report failed sign assertions for nil values - #1962

Open
a3ylf wants to merge 1 commit into
stretchr:masterfrom
a3ylf:fix/nil-sign-assertions
Open

a3ylf wants to merge 1 commit into
stretchr:masterfrom
a3ylf:fix/nil-sign-assertions

Conversation

@a3ylf

@a3ylf a3ylf commented Sep 16, 2026

Copy link
Copy Markdown

Summary

assert.Positive(t, nil) and assert.Negative(t, nil) now report an assertion failure instead of panicking in reflect.Zero.

Changes

Guard nil before creating the zero value and use the existing comparison-error wording. Extend the sign-assertion tests to check the failure and helper reporting.

Motivation

A missing value passed to a sign assertion should produce a useful failed assertion rather than interrupting the test with a reflection panic. This is a bug fix.

Related issues

No matching issue or competing fix found.

Verification: go test -race ./... and the repository’s generation, formatting and vet scripts pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant