Skip to content

Conversation

@markuspf
Copy link
Member

This is the first part of what used to be #2078.

It rearranges the argument parsing code for DeclareAttribute and NewAttribute, and addresses the issue that the rank argument would be ignored if "mutable" was given.

It would be good if @stevelinton could comment whether this might have been intentional (not being able to rank a tester for a mutable attribute).

rank := args[2];
else
rank := 1;
fi;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should also reject invalid arguments? E.g.:

  mutflag:=false;
  rank:= 1;
  if LEN_LIST(args) = 1 and args[1] in [ true, false ] then
    mutflag := args[1];
  elif LEN_LIST(args) = 1 and IS_INT(args[1]) then
    rank := args[1];
  elif LEN_LIST(args) = 2 and args[1] in [true, false] and IS_INT(args[2]) then
    mutflag := args[1];
    rank := args[2];
  else
    Error("Usage: NewAttribute(...)");
  fi;


atomic FILTER_REGION do
OPER_SetupAttribute(getter, flags, mutflag, filter, rank, name);
OPER_SetupAttribute(getter, flags, mutflag, filter, rank, name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deliberately removed indents like that to reduce spurious diffs without whitespace suppression. Granted, in this particular case it matters little, but for consistency, I'd like to keep it as it was.

@markuspf markuspf force-pushed the refactor-declare-attribute branch from 8a5874f to 936f7d8 Compare January 15, 2018 16:02
@codecov
Copy link

codecov bot commented Jan 15, 2018

Codecov Report

Merging #2080 into master will decrease coverage by 6.53%.
The diff coverage is 85.04%.

@@            Coverage Diff             @@
##           master    #2080      +/-   ##
==========================================
- Coverage   67.84%   61.31%   -6.54%     
==========================================
  Files         489      493       +4     
  Lines      255602   260657    +5055     
==========================================
- Hits       173420   159811   -13609     
- Misses      82182   100846   +18664
Impacted Files Coverage Δ
lib/oper.g 71.02% <84.61%> (-3.63%) ⬇️
hpcgap/lib/oper.g 71.83% <85.45%> (-0.11%) ⬇️
lib/attr.gi 0% <0%> (-100%) ⬇️
lib/teachm2.g 0% <0%> (-100%) ⬇️
grp/imf.gi 0% <0%> (-84.96%) ⬇️
lib/proto.gi 0% <0%> (-83.34%) ⬇️
lib/ctblauto.gi 0% <0%> (-82.41%) ⬇️
lib/ctbllatt.gi 0% <0%> (-80.72%) ⬇️
lib/teaching.g 2.45% <0%> (-77.15%) ⬇️
lib/schursym.gi 5.2% <0%> (-62.24%) ⬇️
... and 299 more

This is the result of trying to fix a bug in DeclareAttribute where
if the user called it with the same name but different filters,
the attributes would be setup correctly, but the second would not be
added to the list ATTRIBUTES.

The argument parsing made it impossible to give "mutable" and a rank
for the attribute: If one gave "mutable", the rank would be ignored.
@markuspf markuspf force-pushed the refactor-declare-attribute branch from 936f7d8 to a8bf825 Compare January 15, 2018 16:08
@markuspf markuspf closed this Jan 15, 2018
@markuspf markuspf deleted the refactor-declare-attribute branch January 15, 2018 16:11
olexandr-konovalov pushed a commit to gap-system/gap-distribution that referenced this pull request Jan 25, 2018
Loading them causes error as uncovered by refactoring
DeclareAttribute (gap-system/gap#2080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants