Skip to content

fix(rule): check all type specs in redefines-builtin-id group - #1931

Closed
Hrushikesh-ramilla wants to merge 1 commit into
revive-lint:masterfrom
Hrushikesh-ramilla:fix/redefines-builtin-id-grouped-types
Closed

Hrushikesh-ramilla wants to merge 1 commit into
revive-lint:masterfrom
Hrushikesh-ramilla:fix/redefines-builtin-id-grouped-types

Conversation

@Hrushikesh-ramilla

Copy link
Copy Markdown

Description

Fixes #1866.

In
ule/redefines_builtin_id.go, the oken.TYPE branch previously examined only
.Specs[0]. Consequently, in a grouped type declaration (e.g. ype ( A int; len int )), declarations after the first one that shadowed predeclared identifiers were skipped without warning.

Changes

  • Updated oken.TYPE branch in
    ule/redefines_builtin_id.go to iterate over all specs in
    .Specs.
  • Reported failures on the specific ypeSpec node so that the exact location in the group is highlighted.
  • Added regression test cases in estdata/redefines_builtin_id.go covering grouped type declarations that shadow built-in functions and types.

Verification

  • Tested with go test -v ./test -run TestRedefinesBuiltinID (verified failure on old code and pass on new code).
  • Ran all package tests with go test ./....
  • Verified formatting with gofmt and linting with
    evive.

@Hrushikesh-ramilla

Copy link
Copy Markdown
Author

Closing in favor of earlier PR #1922.

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