From 11d504e8f43dc6133f2cd230a8f3249d365f4238 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Sun, 16 Jan 2022 17:49:13 +0100 Subject: [PATCH] retain the string "[]" as is, instead of converting it to '[]' (i.e., "") This addresses #1215. --- src/machine/system_calls.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 { -- 2.54.0