diff --git a/crates/nu-command/src/formats/to/nuon.rs b/crates/nu-command/src/formats/to/nuon.rs index 7c1f7fb994..db7294482c 100644 --- a/crates/nu-command/src/formats/to/nuon.rs +++ b/crates/nu-command/src/formats/to/nuon.rs @@ -215,7 +215,11 @@ static NEEDS_QUOTES_REGEX: Lazy = Lazy::new(|| { fn needs_quotes(string: &str) -> bool { // These are case-sensitive keywords match string { - "true" | "false" | "null" => return true, + // `true`/`false`/`null` are active keywords in JSON and NUON + // `&&` is denied by the nu parser for diagnostics reasons + // (https://github.com/nushell/nushell/pull/7241) + // TODO: remove the extra check in the nuon codepath + "true" | "false" | "null" | "&&" => return true, _ => (), }; // All other cases are handled here diff --git a/crates/nu-command/tests/format_conversions/nuon.rs b/crates/nu-command/tests/format_conversions/nuon.rs index 65322253aa..29a381ab3b 100644 --- a/crates/nu-command/tests/format_conversions/nuon.rs +++ b/crates/nu-command/tests/format_conversions/nuon.rs @@ -330,7 +330,9 @@ fn quotes_some_strings_necessarily() { '-11.0..-15.0', '11.0..-15.0', '-11.0..15.0', '-11.0..<-15.0', '11.0..<-15.0', '-11.0..<15.0', '-11.0..', '11.0..', '..15.0', '..-15.0', '..<15.0', '..<-15.0', - '2000-01-01', '2022-02-02T14:30:00', '2022-02-02T14:30:00+05:00' + '2000-01-01', '2022-02-02T14:30:00', '2022-02-02T14:30:00+05:00', + ',', + '&&' ] | to nuon | from nuon | describe "# ));