Skip to content

Commit 81b3985

Browse files
committed
feat: add help suggestion to disambiguate parsing order with intersection
1 parent a41aaa1 commit 81b3985

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

pomsky-lib/src/diagnose/help.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ pub(super) fn get_compiler_help(kind: &CompileErrorKind, _span: Span) -> Option<
175175
.to_string(),
176176
)
177177
}
178+
CompileErrorKind::BadIntersection => Some(
179+
"One character sets can be intersected.\n\
180+
Parentheses may be required to clarify the parsing order."
181+
.to_string(),
182+
),
178183

179184
_ => None,
180185
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! expect=error
2+
[w] & [d] [s]
3+
-----
4+
ERROR: Intersecting these expressions is not supported. Only character sets can be intersected.
5+
HELP: One character sets can be intersected.
6+
Parentheses may be required to clarify the parsing order.
7+
SPAN: 0..13
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! expect=error
2+
'a' & ''
3+
-----
4+
ERROR: Intersecting these expressions is not supported. Only character sets can be intersected.
5+
HELP: One character sets can be intersected.
6+
Parentheses may be required to clarify the parsing order.
7+
SPAN: 0..8
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! expect=error
2+
[w] & 'ab'
3+
-----
4+
ERROR: Intersecting these expressions is not supported. Only character sets can be intersected.
5+
HELP: One character sets can be intersected.
6+
Parentheses may be required to clarify the parsing order.
7+
SPAN: 0..10
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! expect=error
2+
'a' & 'b' $
3+
-----
4+
ERROR: Intersecting these expressions is not supported. Only character sets can be intersected.
5+
HELP: One character sets can be intersected.
6+
Parentheses may be required to clarify the parsing order.
7+
SPAN: 0..11
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'a' & 'b'
2+
-----
3+
[a&&b]

0 commit comments

Comments
 (0)