bugGNU Octave - Bugs: bug #60143, Error "function called with...

 
 

bug #60143: Error "function called with too many outputs" when assigning to a property with set method

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Sun 28 Feb 2021 08:22:29 PM UTC
   
 
Category:  Interpreter Severity:  4 - Important
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 06 Mar 2021 01:19:09 PM UTC, comment #19: 

I opened bug #60181 for the differences in behavior identified in comment #16.

Closing report.

Markus Mützel <mmuetzel>
Group administrator
Tue 02 Mar 2021 09:28:12 PM UTC, comment #18: 

This works for me so I've changed the status to "Fixed".  I didn't close it in case we want to work on the Matlab differences Markus identified in comment #16.  Or, we could close this Regression report and open up a new issue report about the Matlab incompatibility.

Rik <rik5>
Group administrator
Tue 02 Mar 2021 12:00:07 PM UTC, comment #17: 

Just FTR, the patch in comment #10 works for me on Windows, thanks.
Trying the pushed cset is s/th for tomorrow night at the earliest for me.

Philip Nienhuis <philipnienhuis>
Group Member
Tue 02 Mar 2021 08:12:12 AM UTC, comment #16: 

Re comment #11: I tried with the attached classes in Matlab R2020b:

>> a = bug60143_value;
>> a.t = 4
The set function for property 't' must return an instance of class 'bug60143_value'.

>> a.u = 3
method set.u

a =

  bug60143_value with properties:

    t: []
    u: 3

>> b = bug60143_handle;
>> b.t=2
method set.t
In set function for property 't', the class of the output object is 'double'; the class of the input object is 'bug60143_handle'. They should be the same.

>> b.u = 4
method set.u

b =

  bug60143_handle with properties:

    t: []
    u: 4


The syntax highlighter in its editor marks the set function for u in class `bug60143_value` with an error highlight "Set Methods must have at most one output.". But -- surprisingly -- it still seems to work (ignoring the extra output).

It looks like it is possible that a set function of a handle class returns a different instance of the same class. That's interesting. I didn't know this was possible.

I didn't check yet how Octave would behave in these cases.

(file #50965, file #50966)

Markus Mützel <mmuetzel>
Group administrator
Tue 02 Mar 2021 01:13:10 AM UTC, comment #15: 

I pushed the following changeset.  Marking as ready for test.

http://hg.savannah.gnu.org/hgweb/octave/rev/aef9c5caedcd

John W. Eaton <jwe>
Group administrator
Mon 01 Mar 2021 10:07:29 PM UTC, comment #14: 

OK.  I can push the change.  I was asking about the other things because maybe additional checking is expected when defining these methods.

John W. Eaton <jwe>
Group administrator
Mon 01 Mar 2021 09:52:42 PM UTC, comment #13: 

Re: Comment #10, the patch does fix the problem for the sample code in this report.  I don't have access to Matlab so I cannot test the other conditions in comment #11 that you want.

Rik <rik5>
Group administrator
Mon 01 Mar 2021 09:50:58 PM UTC, comment #12: 

@Rik:
I retract that statement, it was an error on my side (on Linux I had commented out the two offending lines in ConfusionMatrixChart.m - made no difference to the demo's).
Apologies.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 01 Mar 2021 08:41:14 PM UTC, comment #11: 

Does Matlab throw an error or display a warning if the definition of a set method in a value class does not have a return value?

What about a set method in a value class that is defined with more than one output?  Or a set method in a handle class that is defined with one or more outputs?

What about get methods that are defined with something other than one output?

John W. Eaton <jwe>
Group administrator
Mon 01 Mar 2021 08:08:46 PM UTC, comment #10: 

Could someone try the attached patch and see whether it solves the problem?



(file #50964)

John W. Eaton <jwe>
Group administrator
Mon 01 Mar 2021 07:45:06 PM UTC, comment #9: 

@Philip: If the test case works for you on Linux, could you report the hg id that you are using?  It may be that we can use an abbreviated 'hg bisect' sequence to find the changeset that introduced this regression.

Rik <rik5>
Group administrator
Mon 01 Mar 2021 06:26:21 PM UTC, comment #8: 

I can confirm the test case bug60143.m that Markus made fails on dev Linux, but passes with 6.2.  Upgrading the severity to Important.

Rik <rik5>
Group administrator
Mon 01 Mar 2021 05:56:57 PM UTC, comment #7: 

Thanks Markus, setting status to 'confirmed'.

Intriguing that it works on my Linux box with dev Octave.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 01 Mar 2021 05:46:23 PM UTC, comment #6: 

With that file, I'm seeing the same error on Windows and Linux.

I'm pretty confident that the minimal example in comment #4 exhibits the same bug.

This is a regression with respect to Octave 6 where the same code executes correctly.

Markus Mützel <mmuetzel>
Group administrator
Mon 01 Mar 2021 05:32:44 PM UTC, comment #5: 

Ah yes, sorry, confusionmat is also post-1.4.3.
Get it here:
https://sourceforge.net/p/octave/statistics/ci/default/tree/inst/confusionmat.m
or use the attached.

(file #50959)

Philip Nienhuis <philipnienhuis>
Group Member
Mon 01 Mar 2021 11:27:29 AM UTC, comment #4: 

I tried to reproduce with the instructions in comment #0. But I got a different error:

error: 'confusionmat' undefined near line 98, column 98

The 'confusionmat' function belongs to the statistics package from
Octave Forge but has not yet been implemented.

Please read <https://www.octave.org/missing.html> to learn how you can
contribute missing functionality.
error: called from
    confusionchart at line 98 column 22


I'm not sure if this is the same bug. But I get a similar error with the attached much simpler class:

>> a = bug60143;
>> a.t = 1
error: set.t: function called with too many outputs
error: called from
    set.t


This was with a build from the default branch on Windows 10. I haven't tried on Linux yet.


(file #50955)

Markus Mützel <mmuetzel>
Group administrator
Mon 01 Mar 2021 07:19:47 AM UTC, comment #3: 

Yeah I know about that change in the interpreter.

If -as you seem to imply- there should also be an error on Linux, can you pin down the coding error in ConfusionMatrixChart.m?
I can't, but again, my classdef skills are a bit lacking.

Anyway the fact that it behaves differently on Window and Linux shouldn't happen.

I tried with the same hgid's, i.e., both before and after applying JWE's patch from bug #60079 comment #27. No difference between those hgid's on either platform but different behavior between platforms.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 01 Mar 2021 04:59:27 AM UTC, comment #2: 

The fact that it works with 6.2, but not the development branch, is not surprising.

jwe changed the interpreter (see the NEWS file for 7.0) so that it automatically detects when a function is being called with too many inputs or too many outputs.

Why it should work on Linux (7.0) but not on Windows (7.0) is mysterious.  Is the Windows version the same hg id as the Linux one?

Rik <rik5>
Group administrator
Sun 28 Feb 2021 08:24:28 PM UTC, comment #1: 

Forgot to mention: works fine with Octave-6.2.0 on Windows.

Philip Nienhuis <philipnienhuis>
Group Member
Sun 28 Feb 2021 08:22:29 PM UTC, original submission:  

When running the demos in the contributed function confusionchart.m (patch #9985) with Octave-7.0.0 on Windows the following error is emitted:

:
error: set.FontName: function called with too many outputs
error: called from
    set.FontName
    ConfusionMatrixChart at line 97 column 21
    confusionchart at line 125 column 6


When running the function in Octave-7.0.0 on Linux this error doesn't occur and the demos work nicely.

I have no idea how to break this down into a smaller example, I'm not very familiar with classdef.
So I can only offer the folowing steps to reproduce:

  • download the confusionchart.m and ConfusionMatrixChart.m functions from patch #9985 (attached for convenience here as well) into a folder in the search path
  • if needed install statistics package
  • pkg load statistics

run demo 3:
Yt = {'Positive', 'Positive', 'Positive', 'Negative', 'Negative' }
Yp = {'Positive', 'Positive', 'Negative', 'Negative', 'Negative' }
cm = confusionchart ( Yt, Yp )

Philip Nienhuis <philipnienhuis>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #50965:  bug60143_value.m added by mmuetzel (270B - text/plain)
file #50966:  bug60143_handle.m added by mmuetzel (348B - text/plain)
file #50964:  set-method-diffs.txt added by jwe (1KiB - text/plain)
file #50959:  confusionmat.m added by philipnienhuis (7KiB - text/plain)
file #50955:  bug60143.m added by mmuetzel (182B - text/plain)
file #50951:  confusionchart.m added by philipnienhuis (5KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2021-03-06 mmuetzel Open/ClosedOpen Closed
    2021-03-02 rik5 StatusReady For Test Fixed
    2021-03-02 mmuetzel Attached File- Added bug60143_value.m, #50965
        Attached File- Added bug60143_handle.m, #50966
    2021-03-02 jwe StatusConfirmed Ready For Test
    2021-03-01 jwe Attached File- Added set-method-diffs.txt, #50964
    2021-03-01 rik5 Severity3 - Normal 4 - Important
    2021-03-01 philipnienhuis StatusNone Confirmed
    2021-03-01 mmuetzel Item GroupUnexpected Error or Warning Regression
        Operating SystemMicrosoft Windows Any
        Summary(Windows) classdef error &quot;function called with too many outputs&quot; Error "function called with too many outputs" when assigning to a property with set method
    2021-03-01 philipnienhuis Attached File- Added confusionmat.m, #50959
    2021-03-01 mmuetzel Attached File- Added bug60143.m, #50955
    2021-02-28 philipnienhuis Attached File- Added ConfusionMatrixChart.m, #50950
        Attached File- Added confusionchart.m, #50951

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code