[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #54966] Error when assigning array to an objec
From: |
Martynas |
Subject: |
[Octave-bug-tracker] [bug #54966] Error when assigning array to an object implementing subsasgn() subscripted using "{}" |
Date: |
Mon, 5 Nov 2018 16:55:16 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0; Waterfox) Gecko/20100101 Firefox/56.2.5 |
URL:
<https://savannah.gnu.org/bugs/?54966>
Summary: Error when assigning array to an object implementing
subsasgn() subscripted using "{}"
Project: GNU Octave
Submitted by: mpata
Submitted on: Mon 05 Nov 2018 11:55:15 PM EET
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 4.4.1
Operating System: Microsoft Windows
_______________________________________________________
Details:
GNU Octave seems to give an error message when assigning an array with several
elements to an object implementing subsasgn() method subscripted using curled
braces.
Let's say we have a class (implementing the same assignment for "()" and
"{}"):
classdef exampleclass
properties
b = {1, 2};
end
methods
function [obj] = exampleclass ()
end
function [varargout] = subsasgn (obj, IDX, RHS)
switch IDX(1).type
case '()'
IDXcell = IDX;
IDXcell(1).type = '()';
[obj.b] = subsasgn (obj.b, IDXcell, RHS);
varargout = {obj};
case '{}'
IDXcell = IDX;
IDXcell(1).type = '()';
[obj.b] = subsasgn (obj.b, IDXcell, RHS);
varargout = {obj};
otherwise
[varargout] = {builtin('subsasgn', obj, IDX, RHS)};
end
end
end
end
And run a script trying out different assignments:
[ex] = exampleclass();
ex(1) = {2};
ex.b
ex{1} = {3};
ex.b
ex(1:2) = {2, 3};
ex.b
ex{1:2} = {3, 4};
ex.b
In GNU Octave the last assignment (but none of the previous ones) results in
error message (path removed):
ans =
{
[1,1] = 2
[1,2] = 2
}
ans =
{
[1,1] = 3
[1,2] = 2
}
ans =
{
[1,1] = 2
[1,2] = 3
}
error: invalid dot name structure assignment because the structure array is
empty. Specify a subscript on the structure array to resolve.
error: called from
examplescript at line 9 column 8
stopped in ...\examplescript.m at line 9
9: ex{1:2} = {3, 4};
^
In Matlab assignments do not fail:
ans =
1×2 cell array
{[2]} {[2]}
ans =
1×2 cell array
{[3]} {[2]}
ans =
1×2 cell array
{[2]} {[3]}
ans =
1×2 cell array
{[3]} {[4]}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?54966>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #54966] Error when assigning array to an object implementing subsasgn() subscripted using "{}",
Martynas <=