The .tsg below has two bugs:
- Typo on line 3 (
@ehre
should be @here
)
- Use of
@path.context
on line 10 which is never defined on that syntax node
[
(struct_item name: (_) @here)
(enum_item name: (_) @ehre) ;; oops, typo
] {
let @here.context = "%pattern"
}
(scoped_type_identifier) @path {
node s
attr (s) symbol = @path.context ;; oops, not defined
}
I ran it on this test case.
pub enum A {
M(std::string::String),
}
Expected behavior: Either some error message for bug 1, or the usual message for bug 2 (Undefined scoped variable [syntax node scoped_identifier (2, 7)].context
)
Actual behavior:
$ ./bin/tree-sitter-stack-graphs test --grammar . --tsg ./bug.tsg ./testcase.rs
Error: Error running test ./testcase.rs
Caused by:
0: Executing attr ((load 1)) symbol = (scoped [syntax node scoped_type_identifier (2, 7)] 'context) at (10, 3)
1: Expected a syntax node got #null
This seems like a bug to me because I can't think of any legit way for #null
to get into the computation at line 10.
To reproduce:
git clone [email protected]:jorendorff/tree-sitter-rust.git
cd tree-sitter-rust
git checkout jorendorff/internal-error
script/setup
./bin/tree-sitter-stack-graphs test --grammar . --tsg ./bug.tsg ./testcase.rs