]> Repositorios git - scryer-prolog.git/commitdiff
retain the string "[]" as is, instead of converting it to '[]' (i.e., "")
authorMarkus Triska <[email protected]>
Sun, 16 Jan 2022 16:49:13 +0000 (17:49 +0100)
committerMarkus Triska <[email protected]>
Sun, 16 Jan 2022 16:50:20 +0000 (17:50 +0100)
This addresses #1215.

src/machine/system_calls.rs

index 67611cc563db473176e982bed705d79c6bc39d44..c4d4d4d640b7b671d33ade8107507496f67199f3 100644 (file)
@@ -735,8 +735,14 @@ impl MachineState {
     pub fn value_to_str_like(&mut self, value: HeapCellValue) -> Option<AtomOrString> {
         read_heap_cell!(value,
             (HeapCellValueTag::CStr, cstr_atom) => {
-                // avoid allocating a String if possible ...
-                Some(AtomOrString::Atom(cstr_atom))
+                // avoid allocating a String if possible:
+                // We must be careful to preserve the string "[]" as is,
+                // instead of turning it into the atom [], i.e., "".
+                if cstr_atom == atom!("[]") {
+                    Some(AtomOrString::String("[]".to_string()))
+                } else {
+                    Some(AtomOrString::Atom(cstr_atom))
+                }
             }
             (HeapCellValueTag::Atom, (atom, arity)) => {
                 if arity == 0 {