From: no382001 <102482527+no382001@users.noreply.github.com> Date: Tue, 31 Mar 2026 07:48:23 +0000 (+0200) Subject: fix panic in current_prolog_flag/2 when arguments are the same variable X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=6a10c6d6a536d709fce83e126cbef9ea484f9c2d;p=scryer-prolog.git fix panic in current_prolog_flag/2 when arguments are the same variable --- diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 026b1967..c3019e54 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -9233,10 +9233,9 @@ impl Machine { #[inline(always)] pub(crate) fn is_sto_enabled(&mut self) { - self.machine_st.unify_atom( - self.machine_st.occurs_check.flag_value(), - self.machine_st.registers[1], - ); + let a1 = self.deref_register(1); + self.machine_st + .unify_atom(self.machine_st.occurs_check.flag_value(), a1); } #[inline(always)] diff --git a/tests-pl/issue2914.pl b/tests-pl/issue2914.pl new file mode 100644 index 00000000..25d86696 --- /dev/null +++ b/tests-pl/issue2914.pl @@ -0,0 +1,2 @@ +:- initialization(main). +main :- ( current_prolog_flag(X, X) -> write(true) ; write(false) ). diff --git a/tests/scryer/issues.rs b/tests/scryer/issues.rs index 10ca8e24..73d68430 100644 --- a/tests/scryer/issues.rs +++ b/tests/scryer/issues.rs @@ -20,6 +20,13 @@ fn issue2588_load_html() { load_module_test("tests-pl/issue2588.pl", "[element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])]"); } +// issue #2914 +#[test] +#[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")] +fn issue2914_current_prolog_flag_shared_var() { + load_module_test("tests-pl/issue2914.pl", "false"); +} + #[test] #[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")] fn issue3256_load_xml_returns_list() {