From: Markus Triska Date: Sun, 16 Jan 2022 16:49:13 +0000 (+0100) Subject: retain the string "[]" as is, instead of converting it to '[]' (i.e., "") X-Git-Tag: v0.9.0^2~63^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=11d504e8f43dc6133f2cd230a8f3249d365f4238;p=scryer-prolog.git retain the string "[]" as is, instead of converting it to '[]' (i.e., "") This addresses #1215. --- diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 67611cc5..c4d4d4d6 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -735,8 +735,14 @@ impl MachineState { pub fn value_to_str_like(&mut self, value: HeapCellValue) -> Option { 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 {