bugGNU Octave - Bugs: bug #50011, failure to report error on...

 
 

bug #50011: failure to report error on conflicting methods for classdef

Submitter:  A.R. Burgers <arb>
Submitted:  Tue 10 Jan 2017 08:09:35 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Missed Error or Warning
Status:  Ready For Test Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Release: 
Operating System:  * Any Fixed Release:  None
Planned Release:  11.1.0 (current default)
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 26 May 2025 02:31:27 PM UTC, comment #9: 

I'm not exactly sure how to best handle that.

Should we check for duplicate methods and/or properties already on constructing the first object of that class? Would it be ok in general to cache the methods and/or properties on construction of the first object of that class? What should happen (to existing objects or only to new objects?) if the .m file of that classdef or any of the parent classes changes?

Fwiw, Matlab emits an error about duplicate methods or properties in parent classes already when constructing an object of an affected class.
With the changes from here, Octave constructs these objects without any error. But it emits an error about that issue when any of these duplicate methods or properties are attempted to be used.
Is that too late?

Markus Mützel <mmuetzel>
Group administrator
Sat 24 May 2025 08:06:34 AM UTC, comment #8: 

Thanks Markus.

you mention in your commit this should not be flagged at runtime, but at compile time. Another option would be to use a cache for method calls. I think the VM does this for regular function calls, and this would ideally be resolved when the VM starts handling classdefs.

I hope my approach doesn't add to much to method calling overhead.


A.R. Burgers <arb>
Wed 21 May 2025 03:57:19 PM UTC, comment #7: 

I checked with Matlab R2024b: A similar error is emitted for properties in parent classes.

I rebased the patch to a current head (that part of the source code was moved to a different file in the meantime) and duplicated your solution to the "find_property" member function.
I also added slightly adapted versions of your test case to the test suite, added a commit message, and pushed the changes with you as the author to the default branch:
https://hg.savannah.gnu.org/hgweb/octave/rev/92e77d5e720f

Sorry that this took so extremely long (more than 8 years) to be reviewed and applied.

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Tue 25 Mar 2025 10:30:00 AM UTC, comment #6: 

I only had a very cursory look into this. Apart from the whitespace issues, the patch looks reasonable (without much thinking on my part).

Do we still need this change after the changes from bug #66930? (I'd guess we do.)
Do we need a similar change for duplicate property definitions in a parent class?

Could we add a test case for this issue (or issues if we need a similar change for properties)?

Markus Mützel <mmuetzel>
Group administrator
Tue 25 Mar 2025 09:50:29 AM UTC, comment #5: 

This was linked from bug #66930 about duplicate definitions in the same classdef. This is about duplicate definitions in derived classes.

Is the patch ready to apply?

Arun Giridhar <arungiridhar>
Group Member
Sat 04 Mar 2017 10:07:37 AM UTC, comment #4: 

I attached a bit a polished version of my patch

(file #39885)

A.R. Burgers <arb>
Sun 05 Feb 2017 09:21:28 PM UTC, comment #3: 

attached file p50011.txt could maybe serve as starting point for a patch. With this patch applied octave run_c.m produces


error: method m_s: conflicting definitions in classes sa and sb


(file #39674)

A.R. Burgers <arb>
Thu 12 Jan 2017 04:09:24 AM UTC, comment #2: 

Confirmed.  Octave always uses the first defined method, rather than throwing an error when there are two choices.

Rik <rik5>
Group administrator
Tue 10 Jan 2017 09:31:17 AM UTC, comment #1: 

something went missing ...
matlab R2015B gives:


>> run_c
Error using c
Method 'm_s' defined in class 'c' has 2 or more conflicting definitions.

Error in run_c (line 1)
ci = c;


A.R. Burgers <arb>
Tue 10 Jan 2017 08:09:35 AM UTC, original submission:  

Running attached run_c.m gives on octave:


ans = sa


matlab R2015B gives:


>> run_c
Error using c
Method 'm_s' defined in class 'c' has 2 or more conflicting definitions.

Error in run_c (line 1)
ci = c;
-verbatim

A.R. Burgers <arb>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #39885:  p50011_v2.txt added by arb (997B - text/plain)
file #39674:  p50011.txt added by arb (1KiB - text/plain)
file #39418:  sa.m added by arb (74B - d2l/unknowntype)
file #39419:  c.m added by arb (86B - d2l/unknowntype)
file #39420:  sb.m added by arb (74B - d2l/unknowntype)
file #39421:  run_c.m added by arb (16B - d2l/unknowntype)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by arb (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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-05-21 mmuetzel StatusConfirmed Ready For Test
        Planned ReleaseNone 11.1.0 (current default)
    2017-03-04 arb Attached File- Added p50011_v2.txt, #39885
    2017-02-05 arb Attached File- Added p50011.txt, #39674
    2017-01-17 jwe Item GroupIncorrect Result Missed Error or Warning
    2017-01-12 rik5 StatusNone Confirmed
    2017-01-10 arb Attached File- Added sa.m, #39418
        Attached File- Added c.m, #39419
        Attached File- Added sb.m, #39420
        Attached File- Added run_c.m, #39421

    Back to the top

    Powered by Savane 3.15-e283.
    Corresponding source code