8000 Compare AST function and channel types by dajiaohuang · Pull Request #1794 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

Compare AST function and channel types - #1794

Open
dajiaohuang wants to merge 3 commits into
dominikh:masterfrom
dajiaohuang:fix/astutil-equal-types
Open

dajiaohuang wants to merge 3 commits into
dominikh:masterfrom
dajiaohuang:fix/astutil-equal-types

Conversation

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

QF1002 calls astutil.Equal while comparing supported, side-effect-free switch conditions. Equal currently panics when the compared struct literal type contains a pointer to a function, and treats channel types with different elements as identical.

For example, repeated comparisons of struct{F *func()}{} panic with unreachable: *ast.FuncType. Comparisons of struct{C chan int}{} == a and struct{C chan string}{} == b produce a tagged-switch suggestion whose second case cannot compile. Compare function type fields and channel element types, including optional typed-nil AST children.

Validation: exercised the actual QF1002 analyzer on these valid Go programs. The pre-fix analyzer panics on the function case; applying its channel suggestion fails compilation with mismatched struct types. PR head a14b9a0 handles the function case and emits no incorrect channel suggestion. Earlier focused astutil tests passed. This is focused analyzer validation, not full-suite or upstream CI acceptance.

The unrelated generic-instantiation change was removed; #1764 tracks it separately.

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