octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #60729] print_usage within classdef constructo


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #60729] print_usage within classdef constructor breaks subsequent calls to the class
Date: Fri, 4 Jun 2021 16:38:48 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?60729>

                 Summary: print_usage within classdef constructor breaks
subsequent calls to the class
                 Project: GNU Octave
            Submitted by: nrjank
            Submitted on: Fri 04 Jun 2021 04:38:46 PM EDT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Unexpected Error or Warning
                  Status: None
             Assigned to: None
         Originator Name: Nicholas Jankowski
        Originator Email: 
             Open/Closed: Open
                 Release: 6.2.0
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

tested on Octave 6.2.1 (hg id: f6f664d1027a) on Windows (zip package
installer)

as mentioned in bug #48682 and originating from the Octave Discourse [1], 
calling print_usage() within a contructor method in a classdef class causes
errors in certain subsequent calls to that class, until a clear -c is called.

Using the following test class myclass:


classdef myclass
## -*- texinfo -*-
## @deftypefn  {} {@var{A} =} myclass (@dots{})
## @end deftypefn

  properties
    A = []
  endproperties
  methods
    function this = myclass(varargin)
      if nargin == 0
        #leave empty
      elseif nargin == 1
        this.A = varargin{1};
      else
        print_usage ();
      endif
    endfunction
  endmethods
endclassdef


running through the nargin = 0, 1 and 2 cases triggers the print usage and
subsequent error:

>> A = myclass(), A.A
A =

  myclass object with properties:

      A: [0x0 double]

ans = [](0x0)
>> A = myclass(1), A.A
A =

  myclass object with properties:

      A: [1x1 double]

ans = 1
>> A = myclass(3,4), A.A
error: Invalid call to myclass.  Correct usage is:

-- A = myclass (...)

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at https://www.octave.org and via the help@octave.org
mailing list.
>> A = myclass(), A.A
A =

  myclass object with properties:

      A: [0x0 double]

ans = [](0x0)
>> A = myclass(1), A.A
error: class not found: myclass
error: called from
    myclass at line 14 column 16

The print_usage appears to actually execute okay (at least it displays the
right help text), but for some reason it breaks subsequent attempts to assign
a value to class properties. and only after a 'clear -c' does it return to
normal.

adding in a breakpoint, stepping through print_usage and trying `A =
myclass(1)` at each line, the "class not found" error occurs immediately after
the line 62:


[text, format] = get_help_text (fullname);


as that's a compiled function I wasn't able to step through further, and I
didn't see anything particularly obvious with a glance at corefcn\help.cc that
would explain this.

[1] https://octave.discourse.group/t/classdef-inconsistent-testing-errors/




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60729>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]