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

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

[Octave-bug-tracker] [bug #48682] print_usage fails within classdef bloc


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #48682] print_usage fails within classdef block
Date: Fri, 4 Jun 2021 14:59:08 -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

Follow-up Comment #4, bug #48682 (project octave):

this just popped up again in an Octave discourse conversation [1]. print_usage
within the classdef constructor causes some odd behavior that was originally
thought to be a classdef/BIST problem. 

the following simple class triggers the particular error:

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


For some reason it only affects attempts to assign a value to class
properties. and only after a 'clear -c' does it return to normal. 

calling `help myclass` works fine now, so wondering if the earlier comment #3
thought that fixing print_usage would be 'fairly easy' is still the case.

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

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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