Am 11.01.21 um 20:21 schrieb Allin Cottrell:
On Mon, 11 Jan 2021, Artur Tarassow wrote:
> Am 11.01.21 um 01:29 schrieb Allin Cottrell:
>> On Sun, 10 Jan 2021, Sven Schreiber wrote:
>>
>>> Hi,
>>> another minor question before release. Consider this example:
>>>
>>> <hansl>
>>> strings S = defarray("a")
>>> print S[i] # no output, no reaction
>>> </hansl>
>>>
>>> I _don't_ expect this to work, that's not the point. But
shouldn't
>>> there
>>> be some kind of parsing error?
>>
>> Yes. Fixed.
>
> Thanks for the quick fix, Allin. However, I expected to be able to
> catch the error by
>
> <hansl>
> strings S = defarray("a")
> catch print S[i]
> eval $error
> </hansl>
>
> but I get the error message:
> "> S[i]
> The symbol 'i' is undefined"
You're getting a warning, no?
<hansl>
strings S = defarray("a")
catch print S[i]
eval $error
print "still going!"
</hansl>
<output>
? strings S = defarray("a")
? catch print S[i]
> S[i]
The symbol 'i' is undefined
? eval $error
2
still going!
</output>
Interesting, indeed it works but only outside a function. I ran this
within a function where it stops hard:
<hansl>
set verbose off
clear
set assert stop
function void test_print_strarray_unvalid_idx (void)
print "Start testing print command."
# Given
strings S = defarray("a")
scalar err_expected = TRUE
# When
catch print S[i]
scalar err_actual = $error
print err_actual
print "still going!"
# Then
assert(err_actual == err_expected)
end function
test_print_strarray_unvalid_idx()
</hansl>
Artur