8000 Fix composite literal AST equality by dajiaohuang · Pull Request #1800 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content
8000

Fix composite literal AST equality - #1800

Open
dajiaohuang wants to merge 1 commit into
dominikh:masterfrom
dajiaohuang:fix/astutil-equal-composite
Open

dajiaohuang wants to merge 1 commit into
dominikh:masterfrom
dajiaohuang:fix/astutil-equal-composite

Conversation

@dajiaohuang
@dajiaohuang dajiaohuang commented Oct 1, 2026 •
Copy link
Copy Markdown

QF1002 compares each case operand using astutil.Equal. The composite-literal loop compares the second literal elements to themselves, so distinct array literals are treated as equal and the suggested tagged switch changes behavior.

For example, conditions [1]int{1} == a and [1]int{2} == b are incorrectly combined into a switch on the first literal. With a=[1]int{0} and b=[1]int{2}, the original second branch runs, but the suggested rewrite misses it. Compare corresponding elements across the two literals.

Validation: the actual pre-fix QF1002 analyzer emits that suggestion; applying it changes the example result from 2 to 0. PR head 46d738d emits no suggestion for those distinct operands. Earlier focused AST equality regressions passed. This does not claim full-suite or current upstream CI acceptance.

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

0