Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parser/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl ParsingError {
"This is only valid in some contexts, like a right-hand assignment or a function argument.",
),
Self::NonAssociativeOperator(_) => Some(
"Some operators can't be chained to avoid logical errors, such as comparison ones.\n\
"Some operators cannot be chained because doing so could lead to logical errors. Comparison operators are one example.\n\
Example: write `a == b && b == c` instead of `a == b == c`.",
),
Self::ExpectedIdentifier(_, _) => Some(
Expand Down
9 changes: 9 additions & 0 deletions tests/by-util/test_awk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ fn write_to_dev_full_does_not_panic() {
);
}

// Chaining non-associative operators must report the diagnostic's help text.
#[test]
fn chained_comparison_reports_help_text() {
ucmd()
.arg("BEGIN { p < q < r }")
.run()
.stderr_contains("Some operators cannot be chained");
}

#[test]
fn array_single_index_get_set() {
ucmd()
Expand Down
Loading