nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: tweag/nickel
Pull request #853 (2022-10-04 15:53:56)

Double quote simple strings in the pretty printer
The pretty printer neglected to double quote strings appearing as `Term::Str` in terms. This change adds double quoting together with a test to ensure parity with `StrChunks` pretty printing.


Patch:
diff --git a/src/pretty.rs b/src/pretty.rs
index 27b22a71..2438675c 100644
--- a/src/pretty.rs
+++ b/src/pretty.rs
@@ -261,7 +261,7 @@ where
             Null => allocator.text("null"),
             Bool(v) => allocator.as_string(v),
             Num(v) => allocator.as_string(v),
-            Str(v) => allocator.escaped_string(v),
+            Str(v) => allocator.escaped_string(v).double_quotes(),
             StrChunks(chunks) => {
                 let multiline = chunks.len() > 1;
                 let nb_perc = chunks


Test patch:
diff --git a/tests/pretty.rs b/tests/pretty.rs
index ad4ed55d..2289e0c5 100644
--- a/tests/pretty.rs
+++ b/tests/pretty.rs
@@ -1,5 +1,5 @@
 use nickel_lang::pretty::*;
-use nickel_lang::term::RichTerm;
+use nickel_lang::term::{RichTerm, StrChunk, Term};
 use nickel_lang_utilities::parse;
 use pretty::BoxAllocator;
 
@@ -138,3 +138,11 @@ fn importing() {
 fn overriding() {
     check_file("overriding.ncl");
 }
+
+#[test]
+fn str_vs_strchunks() {
+    assert_eq!(
+        pretty(&Term::Str("string".to_string()).into()),
+        pretty(&Term::StrChunks(vec![StrChunk::Literal("string".to_string())]).into())
+    );
+}