From cf8325bb263ec551e69636483eb5a54dc7c4a7b3 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Wed, 3 Apr 2024 19:06:01 +0200 Subject: [PATCH] feat: add note for clarifying regexp error --- lib/src/compiler/tests/testdata/errors/123.in | 6 ++++++ lib/src/compiler/tests/testdata/errors/123.out | 7 +++++++ lib/src/re/parser.rs | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lib/src/compiler/tests/testdata/errors/123.in create mode 100644 lib/src/compiler/tests/testdata/errors/123.out diff --git a/lib/src/compiler/tests/testdata/errors/123.in b/lib/src/compiler/tests/testdata/errors/123.in new file mode 100644 index 000000000..1f76af482 --- /dev/null +++ b/lib/src/compiler/tests/testdata/errors/123.in @@ -0,0 +1,6 @@ +rule test { + strings: + $a = /{(foo|bar)/ + condition: + $a +} \ No newline at end of file diff --git a/lib/src/compiler/tests/testdata/errors/123.out b/lib/src/compiler/tests/testdata/errors/123.out new file mode 100644 index 000000000..8a1a05083 --- /dev/null +++ b/lib/src/compiler/tests/testdata/errors/123.out @@ -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 `{`? \ No newline at end of file diff --git a/lib/src/re/parser.rs b/lib/src/re/parser.rs index 191796a47..d55457f94 100644 --- a/lib/src/re/parser.rs +++ b/lib/src/re/parser.rs @@ -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()) }