Skip to content

Commit

Permalink
feat: add note for clarifying regexp error
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Apr 3, 2024
1 parent 6233989 commit cf8325b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/src/compiler/tests/testdata/errors/123.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rule test {
strings:
$a = /{(foo|bar)/
condition:
$a
}
7 changes: 7 additions & 0 deletions lib/src/compiler/tests/testdata/errors/123.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error: invalid regular expression
--> line:3:11
|
3 | $a = /{(foo|bar)/
| ^ repetition operator missing expression
|
= note: did you mean `\{` instead of `{`?
3 changes: 2 additions & 1 deletion lib/src/re/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ impl Parser {
esc_seq, esc_seq
))
}
ErrorKind::RepetitionCountUnclosed
ErrorKind::RepetitionMissing
| ErrorKind::RepetitionCountUnclosed
| ErrorKind::RepetitionCountDecimalEmpty => {
Some("did you mean `\\{` instead of `{`?".to_string())
}
Expand Down

0 comments on commit cf8325b

Please sign in to comment.