Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#5948·tree-sitter

child_by_field_* can return a grandchild through a visible alias of a hidden rule

Author: mgsloanCreated Sep 15, 2026Updated Sep 15, 2026

AI Policy

  • I have read the AI Policy and this issue complies with it.

Problem

For:

typescript
  type T=typeof a.b

tree-sitter parse --cst --no-ranges has this for typeof a.b:

type_query
  "typeof"
  member_expression
    object: identifier `a`
    "."
    property: property_identifier `b`

type_query.child_by_field_name("object") should return None, but instead it returns the identifier. The bug also affects child_by_field_id.

Steps to reproduce

https://github.com/tree-sitter/tree-sitter/compare/master...mgsloan:tree-sitter:test/visible-alias-field-lookup?expand=1

This test generated by Codex+Astra has a synthetic grammar involving an alias of a hidden rule that has fields.

I have not generated a fix. I can do so if that would be helpful. Kindly let me know

Expected behavior

Field lookup should never return a grandchild within the visible tree.

Tree-sitter version (tree-sitter --version)

1b8407d1e718f2a26e2886c03cc55622d8d1d7bd

Operating system/version

Debian

Source: tree-sitter/tree-sitter

View original on GitHubView discussion on GitHub