Skip to content

Commit a4975f4

Browse files
authored
allow a[-8:*] and a[-8:*:2] + basic unit test. closes #1445 (#1455)
1 parent a5ecfc8 commit a4975f4

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/arrayindex.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,16 +827,16 @@ class ArrayIndexORange: public ArrayIndexT
827827

828828
SizeT NIter( SizeT varDim)
829829
{
830-
if( sInit >= varDim) // && s > 0)
831-
throw GDLException(-1,NULL,"Subscript out of range [s:*].",true,false);
832-
if( sInit < 0)
830+
if( sInit < 0)
833831
{
834832
s = sInit + varDim;
835833
if( s < 0)
836834
throw GDLException(-1,NULL,"Subscript out of range [-s:*].",true,false);
837835

838836
return (varDim - s);
839-
}
837+
} else if( sInit >= varDim) // && s > 0)
838+
throw GDLException(-1,NULL,"Subscript out of range [s:*].",true,false);
839+
840840
s = sInit;
841841
return (varDim - s);
842842
}

testsuite/LIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ test_angles.pro
22
test_arg_present.pro
33
test_array_equal.pro
44
test_array_indices.pro
5+
test_array_indices_star.pro
56
test_base64.pro
67
test_binfmt.pro
78
test_bug_1779553.pro

testsuite/test_array_indices_star.pro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
; https://github.com/gnudatalanguage/gdl/issues/1445
2+
pro test_array_indices_star
3+
a=cindgen(32)
4+
res=EXECUTE('print, a[-8:*]')
5+
if ~res then EXIT, status=1
6+
end

0 commit comments

Comments
 (0)