Skip to content

Commit

Permalink
feat: add help suggestion to disambiguate parsing order with intersec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Aloso committed Dec 21, 2024
1 parent a41aaa1 commit 81b3985
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pomsky-lib/src/diagnose/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ pub(super) fn get_compiler_help(kind: &CompileErrorKind, _span: Span) -> Option<
.to_string(),
)
}
CompileErrorKind::BadIntersection => Some(
"One character sets can be intersected.\n\
Parentheses may be required to clarify the parsing order."
.to_string(),
),

_ => None,
}
Expand Down
7 changes: 7 additions & 0 deletions pomsky-lib/tests/testcases/intersections/e_multiple.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! expect=error
[w] & [d] [s]
-----
ERROR: Intersecting these expressions is not supported. Only character sets can be intersected.
HELP: One character sets can be intersected.
Parentheses may be required to clarify the parsing order.
SPAN: 0..13
7 changes: 7 additions & 0 deletions pomsky-lib/tests/testcases/intersections/e_string_empty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! expect=error
'a' & ''
-----
ERROR: Intersecting these expressions is not supported. Only character sets can be intersected.
HELP: One character sets can be intersected.
Parentheses may be required to clarify the parsing order.
SPAN: 0..8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! expect=error
[w] & 'ab'
-----
ERROR: Intersecting these expressions is not supported. Only character sets can be intersected.
HELP: One character sets can be intersected.
Parentheses may be required to clarify the parsing order.
SPAN: 0..10
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! expect=error
'a' & 'b' $
-----
ERROR: Intersecting these expressions is not supported. Only character sets can be intersected.
HELP: One character sets can be intersected.
Parentheses may be required to clarify the parsing order.
SPAN: 0..11
3 changes: 3 additions & 0 deletions pomsky-lib/tests/testcases/intersections/strings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'a' & 'b'
-----
[a&&b]

0 comments on commit 81b3985

Please sign in to comment.