bugGNU Octave - Bugs: bug #50010, Index error message "error:...

 
 

bug #50010: Index error message "error: a(5): out of bound 1", et al. have bracket type match

Submitted by:  Dan Sebald <sebald>
Submitted on:  Tue 10 Jan 2017 03:03:46 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Inaccurate Result
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Tue 10 Jan 2017 05:58:05 PM UTC, comment #3:

A lot of code hunks in the patch, but it all looks pretty straightforward. Tested a build here and it works. Thanks.

Dan Sebald <sebald>
Tue 10 Jan 2017 10:48:15 AM UTC, comment #2:

The attached patch appears to do the job for me.

At the point where the exception is first thrown, we don't know the type of indexing that was used. That's only known in the octave_cell indexing or indexed assignment methods. So I added try/catch blocks there to set the type of indexing for the exception message that is created later.

(file #39424)

John W. Eaton <jwe>
Project Administrator
Tue 10 Jan 2017 05:19:01 AM UTC, comment #1:

This "index_exception" may be a fairly low level base class (i.e., complex_index_exception looks to be built on index_exception), and it could be that some object other than the one that created the exception displays the message. If that is the case, perhaps it makes more sense to pass the brack type info in at the creation of the index_exception object rather than the ::message() and ::expression() member functions.

Dan Sebald <sebald>
Tue 10 Jan 2017 03:03:46 AM UTC, original submission:

The following examples:

From JWE:

"Yes, the error message should definitely display the type of index that was used. The functions in lo-array-errwarn.{h,cc} should be modified to accept a parameter that specifies the type of index, then that info should be passed at the point of the error. I'm assuming that the type of index is available at that point. If not, then more significant surgery will be required."

It appears that the two routines that construct this message are:

As suggested, probably the easiest thing to do is add input variables to both of these routines such as

index_exception::expression (std::string openparen, std::string closeparen) const

and use openparen in place of "(" and closeparen in place of ")".

Then compile and see where the compiler complains about function mismatch and make the changes there. It just as efficient doing that as it is testing something like index_type. Even more efficient would be passing just a character (i.e., make the inputs char instead of std::string), but I'm not sure if C++ has defined + operator for a string and just a character.

Dan Sebald <sebald>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #39424:  diffs.txt added by jwe (9KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Updated the item)
  • -unavailable- added by sebald (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 10 Jan 2017 10:48:15 AM UTCjweAttached File-=>Added diffs.txt, #39424

    Back to the top


    Powered by Savane 3.1-cleanup1