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

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

[Octave-bug-tracker] [bug #60280] nested method redefines built-in funct


From: Ray Zimmerman
Subject: [Octave-bug-tracker] [bug #60280] nested method redefines built-in function
Date: Tue, 23 Mar 2021 16:51:16 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15

URL:
  <https://savannah.gnu.org/bugs/?60280>

                 Summary: nested method redefines built-in function
                 Project: GNU Octave
            Submitted by: rdzman
            Submitted on: Tue 23 Mar 2021 08:51:15 PM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Regression
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 6.1.0
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

A bug in my code helped uncover some inconsistent behavior between various
versions of Octave and Matlab, with a nested method. Octave 5.2 and Matlab are
consistent with each other and behave as I would expect, and Octave 6.1 and
6.2 have different behavior (from Matlab and from each other) and end up
treating a built-in function as a variable.

If I knew exactly what was causing the issue I suspect I may be able to find a
slightly simpler example, but here is what I was able to reduce it to. I use
the following classdef (attached) ...

classdef classA < handle
    properties
        prop
    end

    methods
        function obj = meth_a(obj)
            isempty([])
            which('isempty')
            obj.prop = @(x)meth_a1(obj, x);

            function meth_a1(obj, x)
                isempty([])
                which('isempty')
            end
        end

        function obj = meth_b(obj, x)
            obj.prop(x);
        end
    end
end


When I construct the object, then call *meth_a* followed by *meth_b*, I get
the following results.

*Octave 6.2.0*

> classA().meth_a().meth_b([]);
ans = 1
'isempty' is a built-in function from the file libinterp/corefcn/data.cc
ans = [](0x0)
'isempty' is a variable


*Octave 6.1.0*

> classA().meth_a().meth_b([]);
ans = 1
'isempty' is a built-in function from the file libinterp/corefcn/data.cc
ans =

  classA object array with properties:

      prop

'isempty' is a variable


*Octave 5.2.0*

> classA().meth_a().meth_b([]);
ans = 1
'isempty' is a built-in function from the file libinterp/corefcn/data.cc
ans = 1
'isempty' is a built-in function from the file libinterp/corefcn/data.cc


*MATLAB R2021a*

>> classA().meth_a().meth_b([]);

ans =

  logical

   1

built-in (/Applications/-math/MATLAB_R2021a.app/toolbox/matlab/elmat/isempty)

ans =

  logical

   1

built-in (/Applications/-math/MATLAB_R2021a.app/toolbox/matlab/elmat/isempty)





    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Tue 23 Mar 2021 08:51:15 PM UTC  Name: classA.m  Size: 421B   By: rdzman

<http://savannah.gnu.org/bugs/download.php?file_id=51124>

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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