bugGNU Octave - Bugs: bug #60489, Erroneous duplicate method...

 
 

bug #60489: Erroneous duplicate method declaration in classdef file does not generate an error

Submitter:  PIERRE LABRECHE <pierre5018>
Submitted:  Fri 30 Apr 2021 09:40:24 PM UTC
   
 
Category:  Classdef Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Missed Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  PIERRE LABRECHE Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 03 May 2021 01:42:00 AM UTC, comment #2: 

Just an observation, in classdef files there can be multiple functions with the same name, as long as they have different calling signatures.  My guess is that it was simplest to just disable duplicate method validation when classdef was first implemented, and no one got around to improving things.

Rik <rik5>
Group administrator
Mon 03 May 2021 01:31:58 AM UTC, comment #1: 

Confirmed.  Changing Summary to be more specific about the problem (classdef methods).

For regular functions, the interpreter is smart enough to issue a warning.  For this code (attached as tst_fcn_dup.m)


function tst_fcn_dup ()
  subfcn1 ();
  subfcn2 ();
endfunction

function subfcn1 ()
  disp ("First definition of subfcn1");
endfunction

function subfcn2 ()
  disp ("calling subfcn2");
endfunction

function subfcn1 ()
  disp ("Second definition of subfcn1");
endfunction


the error message when run is


error: parse error near line 14 of file /home/rik/wip/Projects_Mine/octave-dev/tst_fcn_dup.m

  duplicate subfunction or nested function name

>>> function subfcn1 ()
            ^





(file #51365)

Rik <rik5>
Group administrator
Fri 30 Apr 2021 09:40:24 PM UTC, original submission:  

Octave fails to report an error or a warning when a class declares the same method twice.

Example:


classdef toto
  properties
    a
  endproperties

  methods
    function obj = toto (a)
      obj.a = a
    endfunction

    # double declaration is not flagged as error or warning
    function obj = toto (a)
      obj.a = 50 ;
    endfunction

  endmethods
endclassdef


PIERRE LABRECHE <pierre5018>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51365:  tst_fcn_dup.m added by rik5 (272B - text/x-matlab)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by pierre5018 (Submitted the item)
  • -email is unavailable- added by pierre5018
  •  

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-23 mmuetzel CategoryInterpreter Classdef
    2021-05-03 rik5 Attached File- Added tst_fcn_dup.m, #51365
        StatusNone Confirmed
        Release6.2.0 dev
        Operating SystemMicrosoft Windows Any
        SummaryErroneous duplicate declaration does not generate an error Erroneous duplicate method declaration in classdef file does not generate an error
    2021-04-30 pierre5018 Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code