bugGNU Octave - Bugs: bug #33637, Misleading "invalid use of...

 
 

bug #33637: Misleading "invalid use of end" error message

Submitted by:  Pascal Dupuis <cdemills>
Submitted on:  Fri 24 Jun 2011 02:24:17 PM UTC  
 
Category:  Interpreter Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  John W. Eaton <jwe>
Originator Name:  Pascal Dupuis Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Tue 21 May 2019 10:19:49 PM UTC, comment #8: 

<<<<
And by the way, here's my theory of punctuation:
Instead of a period at the end of each sentence, there should be a tiny clock that shows you how long it took you to write that sentence.

>>>>

(Laurie Anderson, Another Day in America)

Dmitri A. Sergatskov <dasergatskov>
Tue 21 May 2019 09:33:36 PM UTC, comment #7: 

Works for me.  Marking as fixed and closing report.

Bummer that there can't be a way to indicate how much blood, sweat, toil, and tears went in to a piece of code.

Rik <rik5>
Project Administrator
Tue 21 May 2019 06:23:34 PM UTC, comment #6: 

I pushed the following changeset:

  http://hg.savannah.gnu.org/hgweb/octave/rev/b453b586da16

It seems to fix the problem for me.  I think it is also safe to say that working on this bug report took far longer than any other one-line fix I've ever made.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Tue 21 May 2019 04:02:36 AM UTC, comment #5: 

It would really be nice to be more informative.  This continues to trip up newbies to Octave.

Rik <rik5>
Project Administrator
Wed 15 May 2019 09:22:33 PM UTC, comment #4: 

Still being reported, and still present in Octave versions 5 and 6.

The Matlab error messages for the two situations discussed here, for reference

>> x(end)

Undefined variable or function 'x'.

>> x(y)

Undefined variable or function 'y'.

Mike Miller <mtmiller>
Project Administrator
Sat 19 Nov 2016 03:16:01 PM UTC, comment #3: 

This behavior is still present in Octave 4.2.0.

Hartmut <hardy>
Thu 18 Feb 2016 05:08:33 AM UTC, comment #2: 

Yes, but you'll get a similar result if you try to index an undefined variable with an undefined variable:

octave:1> a(x)
error: 'x' undefined near line 1 column 3
error: evaluating argument list element number 1

The reason the complaint is about the index instead of the object that is being indexed is because Octave evaluates the argument list first, then looks up the symbol.

However, for the end keyword, we have to first determine the value of the object that is being indexed, so we can determine what "end" means.

So I suppose we could error at that point with a message that says the object is invalid.  I'll try to take a look at this.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Fri 24 Jun 2011 04:29:53 PM UTC, comment #1: 

Confirmed.  Here is simpler code to reproduce the error, assuming matrix a is undefined.

clear a

a(1:end)
error: invalid use of end
error: invalid limit value in colon expression
error: evaluating argument list element number 1

BUT
a(1)
error: `a' undefined near line 3 column 1

OR
a(1:10)
error: `a' undefined near line 3 column 1

Rik <rik5>
Project Administrator
Fri 24 Jun 2011 02:24:17 PM UTC, original submission:  

Hello,

I introduced the following typo in a function code:
if (length(varargin) > 1)
  some_par = varargin(1);
  varargin =  varagin(2:end) % <= notice the typo
else
  some_par = ones(size(x));
endif

This generate the following error message:
"invalid use of end"

The problem is that there is obviously no varagin variable. Could the error clearly point to the fact that the variable associated with the 'end' keyword does not exist, and not about the use of end itself?

Regards

Pascal

Pascal Dupuis <cdemills>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by cdemills (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 15 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-08-13 rik5 Dependencies- => bugs #58830 is dependent
    2019-05-21 rik5 StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2019-05-21 jwe StatusConfirmed => Ready For Test
    2019-05-15 mtmiller Carbon-CopyRemoved 80942 => -
    2019-05-15 mtmiller Dependencies- => bugs #56328 is dependent
    2017-05-16 mtmiller Dependencies- => bugs #50852 is dependent
    2017-03-21 rik5 Dependencies- => bugs #50599 is dependent
    2016-02-18 jwe Assigned toNone => jwe
    2015-02-04 mtmiller Severity3 - Normal => 2 - Minor
        Item GroupInaccurate Result => Incorrect Result
        Release3.4.1 => dev
        Operating SystemGNU/Linux => Any
        SummaryMisleading "Incorrect use of end" message => Misleading "invalid use of end" error message
    2011-06-24 rik5 StatusNone => Confirmed

    Back to the top


    Powered by Savane 3.5