bugGNU Octave - Bugs: bug #52096, meta.class.fromName throws error...

 
 

bug #52096: meta.class.fromName throws error when class name not found.

Submitter:  Piotr Held <jsoh425>
Submitted:  Sat 23 Sep 2017 12:26:23 AM UTC
   
 
Category:  Classdef Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  None Assigned to:  None
Originator Name:  Piotr Held Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 26 Sep 2017 07:45:53 PM UTC, comment #5: 

Piotr, I looked at this for a while but don't see a straightforward way to create an empty meta.class or meta.package object.  There really should be a simple way to construct one of those things, and if there isn't one now, we should fix that.  But I don't really understand the classdef code.

John W. Eaton <jwe>
Group administrator
Tue 26 Sep 2017 05:15:40 PM UTC, comment #4: 

Oops, should be fixed with this change: http://hg.savannah.gnu.org/hgweb/octave/rev/e3fade9160f3

John W. Eaton <jwe>
Group administrator
Tue 26 Sep 2017 05:01:08 PM UTC, comment #3: 

I'm seeing two regressions in the test suite that may be due to this issue.


***** assert <*52096> isempty (meta.class.fromName ("__nonexi$tent_cl@$$__"))
!!!!! regression: http://octave.org/testfailure/?52096
ASSERT errors for:  assert ('isempty','(meta.class.fromName ("__nonexi$tent_cl@$$__"))')

  Location  |  Observed  |  Expected  |  Reason
     []        isempty    (meta.class.fromName ("__nonexi$tent_cl@$$__"))   Strings don't match


and


***** assert <*52096> isempty (meta.package.fromName ("__nonexi$tent_p@ck@ge__"))
!!!!! regression: http://octave.org/testfailure/?52096
ASSERT errors for:  assert ('isempty','(meta.package.fromName ("__nonexi$tent_p@ck@ge__"))')

  Location  |  Observed  |  Expected  |  Reason
     []        isempty    (meta.package.fromName ("__nonexi$tent_p@ck@ge__"))   Strings don't match


Does someone who understands this want to comment?

Rik <rik5>
Group administrator
Mon 25 Sep 2017 08:34:47 PM UTC, comment #2: 

There is a way to return an empty package or class array (at least from the interpreter). I have not yet figured out how to do it from code. From the interpreter the proper code would be:


meta.class.fromName('inputParser')([])


I don't know if that's of any help though...

Piotr Held <jsoh425>
Mon 25 Sep 2017 08:07:12 PM UTC, comment #1: 

If Matlab does not throw an error for this case, then an empty matrix seems like a better result than an error.  But is there any way for us to also return an empty class or package array?  If we can't create empty package or class arrays, then I suppose there should be a bug report about that if one does not already exist...

In any case, I checked in the change after editing the commit message:

http://hg.savannah.gnu.org/hgweb/octave/rev/4d9ceaf17dda

John W. Eaton <jwe>
Group administrator
Sat 23 Sep 2017 12:26:23 AM UTC, original submission:  

The same happens for meta.package.fromName.
For Matlab these functions simply return an empty (0x0) class array or package array. I wrote a simple patch that returns just an empty object ([](0x0)) instead. The functionality is already built-into Octave in the functions:
cdef_manager::find_class
cdef_manager::find_package.
The only change I made was to call them with the proper argument: error_if_not_found == false.

I am attaching a patch in to this submission.

Piotr Held <jsoh425>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #41872:  meta_no_error_patch.diff added by jsoh425 (2KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-25 jwe CategoryInterpreter Classdef
        Item GroupMatlab Compatibility Unexpected Error or Warning
    2017-09-23 jsoh425 Attached File- Added meta_no_error_patch.diff, #41872

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code