Skip to content

Go: skip extracting ast.ParenExpr nodes#22146

Draft
owen-mc wants to merge 2 commits into
github:mainfrom
owen-mc:owen-mc/skip-parenexpr-extraction
Draft

Go: skip extracting ast.ParenExpr nodes#22146
owen-mc wants to merge 2 commits into
github:mainfrom
owen-mc:owen-mc/skip-parenexpr-extraction

Conversation

@owen-mc

@owen-mc owen-mc commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Parenthesised expressions (ast.ParenExpr) carry no semantic meaning beyond grouping -- their type and value are identical to their child. This change makes the Go extractor "see through" them: instead of emitting a @parenexpr node into the database, we recurse directly into the child expression, passing through the parent label and child index so it takes the slot the paren node would have occupied.

Approach

At the top of extractExpr, before any label or type extraction happens, we check for *ast.ParenExpr and immediately recurse into paren.X with the caller's parent/idx/skipExtractingValue. The old switch-case branch is removed.

Notes

  • The dbscheme.ParenExpr branch declaration is left in tables.go for now to avoid a schema migration in this PR.

Instead of creating a database entry for parenthesised expressions,
extract their child expression directly in their place. This makes the
extracted AST act as if ParenExpr nodes do not exist while still
correctly extracting children.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Go label Jul 9, 2026
Since the extractor no longer produces ParenExpr nodes, deprecate
the class so existing user code gets a warning rather than breaking,
and remove all references from library code where it was used to
look through parentheses.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant