Although this 'enterInCache' is not used in Kernel (the other
signature is used), this is still a logical error.

Because of the usage of DIFF elsewhere, we can not assume
"1 + cache_use" is the biggest position.

Instead, we should use logic like elsewhere: bump position
by DIFF.

- Qian

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/fricas-devel/cbb33a3f-be05-4e7e-a2f2-46e97f467b93%40gmail.com.
diff --git a/src/algebra/kl.spad b/src/algebra/kl.spad
index 0365b60f..143f73c4 100644
--- a/src/algebra/kl.spad
+++ b/src/algebra/kl.spad
@@ -116,7 +116,11 @@ SortedCache(S : CachableSet) : Exports == Implementation where
 
     enterInCache(x : S, equal? : S -> Boolean) ==
         (res := linearSearch(equal?)) case S => res
-        setPosition(x, 1 + cache_use)
+        if cache_use = 0 then
+            pos : N := DIFF
+        else
+            pos : N := DIFF + position cache(cache_use - 1)
+        setPosition(x, pos)
         insertAtEnd(x)
         x
 

Reply via email to