On Tue, 26 Oct 2021, Artur T. wrote:
Hi all,
I wrote some unit-tests for the recent "end" operator. See here:
https://sourceforge.net/p/gretl/workspace/ci/09881e0435c18730b1a8b54210dc...
I found some edge cases for which the current behavior may be discussed:
<hansl>
clear
set verbose off
WHICH = 1
if WHICH == 1
bundles B = array(0)
eval B[end]
elif WHICH == 2
matrix m = {}
eval m[end]
elif WHICH == 3
strings Sempty = array()
eval Sempty[end]
elif WHICH == 4
open denmark.gdt --quiet --preserve
list L0 = null
eval L0[end]
elif WHICH == 5
open denmark.gdt --quiet --preserve
eval LRM[end] # Index value 2147483647 is out of bounds
elif WHICH == 6
open denmark.gdt --quiet --preserve
eval LRM[(end-1)]
/*
DUM_END: not interpreted for upsym SERIES
> LRM[(end-
The symbol 'end' is undefined
Data error
*/
endif
</hansl>
For the first four cases, I get the message (by the way, no error or warning
is flagged): "Index value 0 is out of bounds". Is this expected, or should it
be handled differently?
I'd say it's expected. And an error is indeed flagged: if you
comment out "set verbose off" you'll see an explicit statement,
"Terminated on error". With verbosity off that's not printed (the
message you're seeing is supposed to be sufficient) but execution
nonetheless stops. If you add the line
print "Still going"
after your endif terminator you'll see it's not reached.
The "end" keyword is not implemented for series. Seems to me it's
arguably both redundant and ambiguous: it could mean $t2 or I
suppose $tmax or $nobs. However, the output when "end" is given
for a series is clearly messy and needs fixing.
Allin