shithub: pprolog

Download patch

ref: 91f737e4effa109cb22bc1b2000f457fa1ad88db
parent: 660d7d81eb1adcc2b108d0b150e3439972b1ec0a
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Wed Jul 7 11:11:18 EDT 2021

Fix compare/3 for variables named _. They are never equal

--- a/builtins.c
+++ b/builtins.c
@@ -247,7 +247,9 @@
 		/* Same type term */
 		switch(t1->tag){
 		case VariableTerm:
-			if(t1->clausenr == t2->clausenr)
+			if(runestrcmp(t1->text, L"_") == 0 && runestrcmp(t2->text, L"_") == 0)
+				result = 1; /* Special case since _ and _ are always different */
+			else if(t1->clausenr == t2->clausenr)
 				result = runestrcmp(t1->text, t2->text);
 			else
 				result = Compare(t1->clausenr, t2->clausenr);