fix(query)!: assert that predicates end in ! or ?
Predicates/directives are documented to end in either `!` or `?`. However, `query.c` allows them to be any valid identifier, and also allows `?` or `!` characters anywhere inside an identifier. This commit removes `?` and `!` from the list of valid identifier characters, and asserts that predicates/directives only *end* in `?` or `!`, respectively. This commit is breaking because you can no longer do something like `(#eq? @capture foo!bar)` (`foo!bar` must now be quoted).
This commit is contained in:
parent
ac13c86675
commit
6cabd9e67f
2 changed files with 20 additions and 6 deletions
|
|
@ -117,12 +117,24 @@ fn test_query_errors_on_invalid_syntax() {
|
|||
|
||||
// Unclosed sibling expression with predicate
|
||||
assert_eq!(
|
||||
Query::new(&language, r"((identifier) (#a)")
|
||||
Query::new(&language, r"((identifier) (#a?)")
|
||||
.unwrap_err()
|
||||
.message,
|
||||
[
|
||||
"((identifier) (#a)", //
|
||||
" ^",
|
||||
"((identifier) (#a?)", //
|
||||
" ^",
|
||||
]
|
||||
.join("\n")
|
||||
);
|
||||
|
||||
// Predicate not ending in `?` or `!`
|
||||
assert_eq!(
|
||||
Query::new(&language, r"((identifier) (#a))")
|
||||
.unwrap_err()
|
||||
.message,
|
||||
[
|
||||
"((identifier) (#a))", //
|
||||
" ^",
|
||||
]
|
||||
.join("\n")
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue