diff --git a/parser/src/diagnostics.rs b/parser/src/diagnostics.rs index ca9b158..81d6fb9 100644 --- a/parser/src/diagnostics.rs +++ b/parser/src/diagnostics.rs @@ -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( diff --git a/tests/by-util/test_awk.rs b/tests/by-util/test_awk.rs index 74a993b..7fda4ae 100644 --- a/tests/by-util/test_awk.rs +++ b/tests/by-util/test_awk.rs @@ -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()