bugGNU Octave - Bugs: bug #65214, Evaluation of properties...

 
 

bug #65214: Evaluation of properties referencing other properties fails

Submitter:  None
Submitted:  Fri 26 Jan 2024 07:58:36 AM UTC
   
 
Category:  Classdef Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Duplicate Assigned to:  jwe
Originator Name:  Alexander Entinger Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 26 Jan 2024 04:57:55 PM UTC, comment #4: 

Added dependency on bug #52582 of which this bug report is essentially a duplicate.  However, no problem to solve it here and then close both of them.

Attached is code from previous bug report.


# Constant property which is dervied from an expression, rather than a
# fixed value, doesn't parse and emits error.
classdef cdef_const_crash
  properties( Constant = true )
    FOO = 2;
    BAR = 4;
    FOOBAR = cdef_const_crash.FOO * cdef_const_crash.BAR;
  end
end


Run


c = cdef_const_crash
error: no such file, '/home/rik/wip/Projects_Mine/octave-dev/cdef_const_crash.m'
error: called from
    <unknown>



(file #55616)

Rik <rik5>
Group administrator
Fri 26 Jan 2024 03:39:09 PM UTC, comment #3: 

OK, thanks for checking.  Fixing this will require a bit more work then.  I'll try to take another look at it.

John W. Eaton <jwe>
Group administrator
Fri 26 Jan 2024 03:36:12 PM UTC, comment #2: 

using matlab 2023b, the original class with MinBug.A works. :

>> obj = MinBug()

obj =

  MinBug with properties:

    A: 1
    B: 2


if i change the

 B = MinBug.A * 2

line to

 B = A * 2

i get an error:

>> obj = MinBug()
Invalid default value for property 'B' in class 'MinBug':
Unrecognized function or variable 'A'.


Nicholas Jankowski <nrjank>
Group Member
Fri 26 Jan 2024 03:22:03 PM UTC, comment #1: 

I'm attaching a copy of my proposed patch, updated with the bug number.

Does the syntax


    B = MinBug.A * 2


work in Matlab?  That won't work in Octave, even with my change.  But with the change, you can use


    B = A * 2


If the CLASSNAME.PROPERTY syntax is supposed to work, then the fix for that is probably similar to the one required for the problem mentioned in this FIXME note in cdef-class.cc:


      // FIXME: default property expression should be able to call static
      //        methods of the class being constructed.  A restricted
      //        CLASSNAME symbol should be added to the scope before
      //        evaluating default value expressions.



(file #55615)

John W. Eaton <jwe>
Group administrator
Fri 26 Jan 2024 07:58:36 AM UTC, original submission:  

Full discussion see here: https://octave.discourse.group/t/how-to-reference-a-const-property-within-an-octave-class/5214

I’m experiencing a problem when I want to reference a constant property member of a class from another property of the very same class. The minimal Octave code showing this problem is this:


classdef MinBug
  properties (Constant = true)
    A = 1
    B = MinBug.A * 2
  end
end


When trying to instantiate a new object via obj = MinBug() this error occurs:


error: no such file, 'PATH_TO_MINBUG/MinBug.m'
error: called from
    <unknown>


Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #55616:  cdef_const_crash.m added by rik5 (270B - text/x-objcsrc)
file #55615:  classdef-prop-init.txt added by jwe (4KiB - text/plain)

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-26 rik5 Attached File- Added cdef_const_crash.m, #55616
        StatusNone Duplicate
        Assigned toNone jwe
        Dependencies- Depends on bugs #52582
    2024-01-26 jwe Attached File- Added classdef-prop-init.txt, #55615

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code