From 0f114a4797830d0484a215dcd0d18900bde87b81 Mon Sep 17 00:00:00 2001 From: Alexander Hulpke Date: Sat, 28 Apr 2018 13:10:25 -0600 Subject: [PATCH] Instead of multiple setter calls, set filters and attribute in one. To avoid deductions changing the type all the time. --- lib/coll.gi | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/coll.gi b/lib/coll.gi index 473039c7e1..e0ad7884c9 100644 --- a/lib/coll.gi +++ b/lib/coll.gi @@ -3058,13 +3058,21 @@ InstallMethod( CanComputeIsSubset,"default: no, unless identical", InstallOtherMethod(SetSize,true,[IsObject and IsAttributeStoringRep,IsObject], 100, # override system setter function(obj,sz) - if not HasSize(obj) then - SetIsEmpty(obj,sz=0); - SetIsTrivial(obj,sz=1); - SetIsNonTrivial(obj,sz<>1); - SetIsFinite(obj,sz<>infinity); +local filt; + if HasSize(obj) and Size(obj)<>sz then + # Make this an ordinary error to enter break loop so that one can + # investigate call order for debugging + Error("size of ",obj," already set to ",Size(obj), + ", cannot be changed to ",sz); fi; - TryNextMethod(); # to enforce size setting + if sz=0 then filt:=IsEmpty; + elif sz=1 then filt:=IsTrivial; + elif sz=infinity then filt:=IsNonTrivial and HasIsFinite; + else filt:=IsNonTrivial and IsFinite; + fi; + filt:=filt and HasSize; + obj!.Size:=sz; + SetFilterObj(obj,filt); end); #############################################################################