Test for unused extra alias

Tests the issue described in #1834
This commit is contained in:
Nat Mote 2022-08-10 07:25:46 -07:00
parent 3739b7794e
commit 0113bd28a4
No known key found for this signature in database
GPG key ID: 7D71116F505E5145
2 changed files with 17 additions and 4 deletions

View file

@ -2,11 +2,12 @@
Method calls
======================================
a.b(c(d.e));
*a.b(c(d.e));
---
(statement
(star_aliased)
(call_expression
(member_expression
(variable_name)

View file

@ -1,7 +1,10 @@
module.exports = grammar({
name: 'aliased_rules',
extras: $ => [/\s/],
extras: $ => [
/\s/,
$.star,
],
rules: {
statement: $ => seq($._expression, ';'),
@ -25,6 +28,15 @@ module.exports = grammar({
alias($.identifier, $.property_name)
)),
identifier: $ => /[a-z]+/
identifier: $ => /[a-z]+/,
// Tests for https://github.com/tree-sitter/tree-sitter/issues/1834
//
// Even though the alias is unused, that issue causes all instances of
// the extra that appear in the tree to be renamed to `star_aliased`.
//
// Instead, this alias should have no effect because it is unused.
star: $ => '*',
unused: $ => alias($.star, $.star_aliased),
}
});
});