Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PositionProperty with from < 1 #2056

Merged
merged 1 commit into from Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/list.gi
Expand Up @@ -1525,8 +1525,8 @@ InstallMethod( PositionProperty,
function( list, func, from )
local i;

if from < 1 then
from:= 1;
if from < 0 then
from:= 0;
fi;
for i in [ from+1 .. Length( list ) ] do
if IsBound( list[i] ) then
Expand Down Expand Up @@ -1557,8 +1557,8 @@ InstallMethod( PositionProperty,
function( list, func, from )
local i;

if from < 1 then
from:= 1;
if from < 0 then
from:= 0;
Copy link
Member

Choose a reason for hiding this comment

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

The exact same bug is in the code 30 lines before, please fix it there, too.

fi;
for i in [ from+1 .. Length( list ) ] do
if func( list[i] ) then
Expand Down
20 changes: 20 additions & 0 deletions tst/testinstall/list.tst
Expand Up @@ -209,5 +209,25 @@ gap> PositionsProperty( ll, ReturnTrue );
gap> PositionsProperty( ll, IsInt );
[ 1, 2, 3 ]

# PositionProperty
gap> ll := [ 1, , "s" ];;
gap> PositionProperty( ll, ReturnTrue, 0);
1
gap> PositionProperty( ll, ReturnTrue, 1);
3
gap> PositionProperty( ll, IsInt, 0);
1
gap> PositionProperty( ll, IsInt, 1);
fail
gap> ll := [ 1, 2, 3 ];;
gap> PositionProperty( ll, ReturnTrue, 0);
1
gap> PositionProperty( ll, ReturnTrue, 1);
2
gap> PositionProperty( ll, ReturnTrue, 2);
3
gap> PositionProperty( ll, ReturnTrue, 3);
fail

#
gap> STOP_TEST("list.tst");