diff --git a/src/opers.cc b/src/opers.cc index 14e22c62fd..e40f266d77 100644 --- a/src/opers.cc +++ b/src/opers.cc @@ -2428,7 +2428,9 @@ static Obj DoMutableAttribute(Obj self, Obj obj) /* call the operation to compute the value */ val = DoOperation1Args( self, obj ); - + if (val == 0) { + ErrorMayQuit("Method for an attribute must return a value", 0, 0); + } /* set the value (but not for internal objects) */ if ( ENABLED_ATTR( self ) == 1 && !IS_MUTABLE_OBJ( obj ) ) { switch ( TNUM_OBJ( obj ) ) { @@ -2473,7 +2475,9 @@ static Obj DoVerboseMutableAttribute(Obj self, Obj obj) /* call the operation to compute the value */ val = DoVerboseOperation1Args( self, obj ); - + if (val == 0) { + ErrorMayQuit("Method for an attribute must return a value", 0, 0); + } /* set the value (but not for internal objects) */ if ( ENABLED_ATTR( self ) == 1 && !IS_MUTABLE_OBJ( obj ) ) { switch ( TNUM_OBJ( obj ) ) { diff --git a/tst/testinstall/oper1.tst b/tst/testinstall/oper1.tst index 7a78b2f5ea..1b41ff1a13 100644 --- a/tst/testinstall/oper1.tst +++ b/tst/testinstall/oper1.tst @@ -76,3 +76,15 @@ gap> List(MethodsOperation(IsMyProperty, 1), x->x.info); # gap> RedispatchOnCondition(); Error, Usage: RedispatchOnCondition(oper[,info],fampred,reqs,cond,val) + +# Check install methods for operations which do not return a value +gap> MyMutAttribute := NewAttribute( "MyMutAttribute", IsObject, "mutable" ); + +gap> MyAttribute := NewAttribute( "MyAttribute", IsObject); + +gap> InstallMethod(MyAttribute, "for a perm group", [IsPermGroup], function(x) end); +gap> InstallMethod(MyMutAttribute, "for a perm group", [IsPermGroup], function(x) end); +gap> MyAttribute(Group((1,2,3))); +Error, Method for an attribute must return a value +gap> MyMutAttribute(Group((1,2,3))); +Error, Method for an attribute must return a value