From 025da8315b070d997bcd439558b483de0537a19a Mon Sep 17 00:00:00 2001 From: no382001 <102482527+no382001@users.noreply.github.com> Date: Tue, 3 Mar 2026 12:34:31 +0100 Subject: [PATCH] load_xml was returning a single term instead of a list of nodes --- src/machine/system_calls.rs | 7 ++++++- tests-pl/issue3256.pl | 5 +++++ tests/scryer/issues.rs | 9 +++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests-pl/issue3256.pl diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index edd08cb5..7453fd33 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -8450,7 +8450,12 @@ impl Machine { match roxmltree::Document::parse(&string.as_str()) { Ok(doc) => { let result = self.xml_node_to_term(doc.root_element())?; - unify!(self.machine_st, self.machine_st.registers[2], result); + let list = sized_iter_to_heap_list( + &mut self.machine_st.heap, + 1, // just one root element + std::iter::once(result), + )?; + unify!(self.machine_st, self.machine_st.registers[2], list); } _ => { self.machine_st.fail = true; diff --git a/tests-pl/issue3256.pl b/tests-pl/issue3256.pl new file mode 100644 index 00000000..77e0bcff --- /dev/null +++ b/tests-pl/issue3256.pl @@ -0,0 +1,5 @@ +:- use_module(library(sgml)). + +test :- load_xml("hello", Es, []), write(Es). + +:- initialization(test). diff --git a/tests/scryer/issues.rs b/tests/scryer/issues.rs index cb321746..10ca8e24 100644 --- a/tests/scryer/issues.rs +++ b/tests/scryer/issues.rs @@ -20,6 +20,15 @@ fn issue2588_load_html() { load_module_test("tests-pl/issue2588.pl", "[element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])]"); } +#[test] +#[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")] +fn issue3256_load_xml_returns_list() { + load_module_test( + "tests-pl/issue3256.pl", + "[element(foo,[],[element(bar,[],[[h,e,l,l,o]])])]", + ); +} + #[test] #[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")] fn issue2949_load_html() { -- 2.54.0