bugGNU Octave - Bugs: bug #49409, Undefined var from subclass

 
 

bug #49409: Undefined var from subclass

Submitter:  Ll <pipeng>
Submitted:  Fri 21 Oct 2016 09:41:00 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Works For Me Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 22 Oct 2016 05:35:25 PM UTC, comment #2: 

Ups you are right, sorry waste your time, i need take care more attention to this details.

Thx. Cya.

Ll <pipeng>
Sat 22 Oct 2016 05:09:26 PM UTC, comment #1: 

Doesn't the error here just mean that you called B with only 1 argument?  You need either a default value


function obj = B(x, y = 0)


or to check the value of nargin


function obj = B(x, y)
  obj@A(x);
  if (nargin > 1)
    obj.y = y;
  else
    obj.y = ## default value
  endif


If you fix that is there still a bug here?

Mike Miller <mtmiller>
Group Member
Fri 21 Oct 2016 09:41:00 PM UTC, original submission:  

Hi, well this is a Matlab example:
pipe@Hi ~/Documentos/Cosas/octave/classes $ cat @A/A.m
classdef A
   properties
      x
      y
   end
   methods
      function obj = A(x)
            obj.x = x;
      end
   end
end
pipe@Hi ~/Documentos/Cosas/octave/classes $ cat @B/B.m
classdef B < A
   methods
      function obj = B(x,y)
         obj@A(x);
         obj.y = y;
      end
   end
end

and from octave

octave:3> B(2)
error: 'y' undefined near line 5 column 18
error: called from
    B at line 5 column 16

Thx. Cya.

Ll <pipeng>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by pipeng (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-10-22 mtmiller Open/ClosedOpen Closed
    2016-10-22 mtmiller CategoryNone Interpreter
        Item GroupNone Incorrect Result
        StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code