Turn off Octave:empty-index warning for --braindead mode?

The following code emits a warning about empty indexing

octave:2> x = 1:3;
octave:3> x()
warning: 'matrix' object indexed with empty index list
ans =

   1   2   3

The code is legal in both Matlab and Octave, but only Octave emits a warning about it. Should we turn off this warning when --braindead mode is used in order to be maximally compatible?

Seems fine to me if it is just for the compatibility mode.

Cool. That was my leaning. I like the warning for Octave code because an empty index really could be a programmer error: 1) they forgot to put the index in that they wanted, or 2) they wanted all of the values and meant to use ‘:’.

I made the change in this cset: octave: a31cf1ec1349.

A recent Matlab will actually complain (MATLAB:subscripting:noSubscriptsSpecified):

Warning: A value of class “double” was indexed with no subscripts specified.
Currently the result of this operation is the indexed value itself, but in a
future release, it will be an error.

Interesting, does that only apply to double arrays? Is it already an error for single or integers?

This post also reminds me of the issue of somehow handling Matlab warning IDs in Octave. Maybe we could have a list of translations? I couldn’t find a relevant bug report but I’m pretty sure we have discussed it a few times before. The oldest thread is probably here:


It must be a very recent version of Matlab. I tried with R2021a and there was no warning.

In a slightly hacky way, I used to rely on the fact that a and a() were the same for a numeric array but could differ if a was an object with a tailored subsref.
Looking for bug reports I received at the time, it seems that Matlab versions around R2019a would display the warning. The warning seems to be disabled by default in R2021a and a warning on is necessary.