bugGNU Octave - Bugs: bug #55746, interpreter fails to instantiate...

 
 

bug #55746: interpreter fails to instantiate classdef with classdef properties

Submitter:  A.R. Burgers <arb>
Submitted:  Wed 20 Feb 2019 12:00:46 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  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

Mon 17 Jun 2019 03:27:45 PM UTC, comment #8: 

Thanks.

Yes, the description of what happens with ans in the base workspace is exactly the same as what was happening with the other bug report.

Closing as fixed.

John W. Eaton <jwe>
Group administrator
Mon 17 Jun 2019 08:40:36 AM UTC, comment #7: 

Current dev versions do not trigger this error anymore, this seems to fixed, possibly by http://hg.savannah.gnu.org/hgweb/octave/rev/946c6f117091

A.R. Burgers <arb>
Mon 11 Mar 2019 10:34:00 PM UTC, comment #6: 

I can confirm this with the attached, adapted from @arb's example.

It seems like the 'ans' variable is being referenced when the class is parsed the first time.

If the class is instantiated first, then it works every subsequent time. If the 'ans' variable is never assigned to or is cleared before parsing the class the first time, then it works.


>> xxx
error: bool cannot be indexed with .
error: called from
    xxx at line 2 column 3


And this is a regression from Octave 5.1, where it works correctly.

(file #46500)

Mike Miller <mtmiller>
Group Member
Mon 04 Mar 2019 07:36:42 PM UTC, comment #5: 

There was an interaction with my .octaverc file.
Here is a hopefully self-contained version. Execute with


octave --no-init-file --no-site-file --norc use_pckg.m



% script use_pckg
pkg('prefix', '/tmp', '/tmp');
ans
ver = version
hg_id = __octave_config_info__.hg_id
whos
if 0
  clear ans
end
cls1_inst = pckg.cls1


After execution of the pkg command ans contains '/tmp/'. Clearing ans allows to instantiate pckg.cls1

A.R. Burgers <arb>
Thu 21 Feb 2019 06:25:51 PM UTC, comment #4: 

Do you have a variable named pckg in the workspace?  I see the same error as you if I do


octave:1> pckg = 'foo'
pckg = foo
octave:2> use_pckg
ver = 6.0.0
hg_id = 81b7bef8192c
error: sq_string cannot be indexed with .
error: called from
    use_pckg at line 5 column 11


Or maybe a function named pckg that returns a string?

That still doesn't explain why you see different results with 6.0.0 vs. 5.0.91.

John W. Eaton <jwe>
Group administrator
Thu 21 Feb 2019 01:25:59 PM UTC, comment #3: 

reverting all local changes doesn't change the result for me:


ver = 6.0.0
hg_id = 81b7bef8192c
error: sq_string cannot be indexed with .
error: called from
    use_pckg at line 5 column 11


There still is some hidden factor at work that my example doesn't capture.

A.R. Burgers <arb>
Thu 21 Feb 2019 05:05:49 AM UTC, comment #2: 

I finally had a chance to try your examples and here's what I see using hg ID 568565a70b5 (note your hg ID has a "+" appended indicating local changes -- what are those changes?)


octave:2> use_pckg
ver = 6.0.0
hg_id = 568565a70b58
cls1_inst =

<object pckg.cls1>


and with my current sources:


octave:2> use_pckg
ver = 6.0.0
hg_id = c65ade411d60
cls1_inst =

pckg.cls1 object with properties:

  c2: [1x1 pckg.cls2]


John W. Eaton <jwe>
Group administrator
Wed 20 Feb 2019 05:41:32 PM UTC, comment #1: 

I've been working on refactoring the way packages are handled and some of my recent (incomplete, as yet) changes are probably the reason this fails now. I'll see about fixing it.

We could use more tests.  Posting examples with expected output is certainly helpful, but it would be even more useful if someone could turn these into patches or changesets that would add them to the test suite in the Octave sources.

John W. Eaton <jwe>
Group administrator
Wed 20 Feb 2019 12:00:46 PM UTC, original submission:  

dev octave fails to instantiate a classdef, that has a property that is initialized to another classdef. See below for how to reproduce, and the octave-5.0.91 and octave-6.0.0 outputs. Apparently the pckg package name in the pckg.cls2 invocation is not recognized as a package, but interpreted as a string.

file lay-out


./use_pckg.m
./+pckg/cls1.m
./+pckg/cls2.m



classdef cls1
  properties
    c2 = pckg.cls2;
  end
end



classdef cls2
end



% script use_pckg
ver = version
hg_id = __octave_config_info__.hg_id
addpath(pwd);
cls1_inst = pckg.cls1


octave-5.0.x output:


ver = 5.0.91
hg_id = b812ed975ea8+
cls1_inst =
<object pckg.cls1>


octave 6.0.0 output:


ver = 6.0.0
hg_id = 568565a70b58+
error: sq_string cannot be indexed with .
error: called from
    use_pckg at line 5 column 11


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 #46500:  xxx.tgz added by mtmiller (245B - application/x-compressed-tar)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-17 jwe StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2019-03-11 mtmiller Attached File- Added xxx.tgz, #46500
        StatusWorks For Me Confirmed
    2019-02-21 jwe StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code