diff --git a/src/compilation_error.rs b/src/compilation_error.rs index 4d629a2..0fc9fc5 100644 --- a/src/compilation_error.rs +++ b/src/compilation_error.rs @@ -67,9 +67,16 @@ impl<'a> Display for CompilationError<'a> { variable, circle.join(" -> "))?; } } + InvalidEscapeSequence{character} => { - writeln!(f, "`\\{}` is not a valid escape sequence", - character.escape_default().collect::())?; + let representation = match character { + '`' => r"\`".to_string(), + '\\' => r"\".to_string(), + '\'' => r"'".to_string(), + '"' => r#"""#.to_string(), + _ => character.escape_default().collect(), + }; + writeln!(f, "`\\{}` is not a valid escape sequence", representation)?; } DuplicateParameter{recipe, parameter} => { writeln!(f, "Recipe `{}` has duplicate parameter `{}`", recipe, parameter)?; diff --git a/tests/integration.rs b/tests/integration.rs index cd99977..5bf39be 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1800,3 +1800,18 @@ echo: stderr: "echo dotenv-value\necho dotenv-value\n", status: EXIT_SUCCESS, } + +integration_test! { + name: invalid_escape_sequence_message, + justfile: r#" +X = "\'" +"#, + args: (), + stdout: "", + stderr: r#"error: `\'` is not a valid escape sequence + | +2 | X = "\'" + | ^^^^ +"#, + status: EXIT_FAILURE, +}