]> Repositorios git - scryer-prolog.git/commitdiff
fix panic in current_prolog_flag/2 when arguments are the same variable
authorno382001 <[email protected]>
Tue, 31 Mar 2026 07:48:23 +0000 (09:48 +0200)
committerno382001 <[email protected]>
Tue, 31 Mar 2026 10:01:00 +0000 (12:01 +0200)
src/machine/system_calls.rs
tests-pl/issue2914.pl [new file with mode: 0644]
tests/scryer/issues.rs

index 026b19672d6f48e45cd8c02fabd13f596a236ff6..c3019e54bb902ea73e797f85972ffcffa5c14209 100644 (file)
@@ -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 (file)
index 0000000..25d8669
--- /dev/null
@@ -0,0 +1,2 @@
+:- initialization(main).
+main :- ( current_prolog_flag(X, X) -> write(true) ; write(false) ).
index 10ca8e240f05c176d974195fd42a51c4e00af776..73d68430059cefa033fdc7281fa1e5bb9c4c4f22 100644 (file)
@@ -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() {