bugGNU Octave - Bugs: bug #34765, can't index scalar in anonymous...

 
 

bug #34765: can't index scalar in anonymous functions

Submitter:  Carnë Draug <carandraug>
Submitted:  Mon 07 Nov 2011 01:06:09 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 15 Mar 2012 05:22:21 PM UTC, comment #4: 
John W. Eaton <jwe>
Group administrator
Wed 14 Mar 2012 08:26:23 PM UTC, comment #3: 

Hi

on 3.6.1 this still occurs for scalars. While the code on the second comment now runs well, the one on the first does not.


octave>  k = 1; in = 0; foo = @(x) in(x); foo (k);
error: can't perform indexing operations for scalar type


However, this runs fine:

in = 0; in(1)


Carnë

Carnë Draug <carandraug>
Group Member
Mon 07 Nov 2011 06:54:54 PM UTC, comment #2: 

This has been fixed on the development branch.  The 3.6.0 release is scheduled for December 2011 (relatively soon) so I can't say whether anyone will backport the fix to the 3.4.X series or just wait for the 3.6.X series to become the new stable supported release.

Rik <rik5>
Group administrator
Mon 07 Nov 2011 01:30:12 AM UTC, comment #1: 

I tried a bit more, and found that the problem is more general. Having a matrix also causes an error


octave>  k = 1; in = [0,1]; foo = @(x) in(x); foo (k)
error: can't perform indexing operations for matrix type


This seems to be fixed on the dev release (thanks Jordi).

Carnë Draug <carandraug>
Group Member
Mon 07 Nov 2011 01:06:09 AM UTC, original submission:  

Hi

if in an anonymous function tries to index a scalar it returns a error. Here's a simple example to replicate the problem:


octave>  k = 1; in = 0; foo = @(x) in(x); foo (k);
error: can't perform indexing operations for scalar type


Back in octave 3.2.4 this worked fine and returned the expected result '0'. This is also the result obtained in at least MatLab R2001b.

Carnë

Carnë Draug <carandraug>
Group Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

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 jordigh (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by carandraug (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-03-15 jwe StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2012-03-14 jordigh StatusFixed Confirmed
        Open/ClosedClosed Open
        Release3.4.3 dev
    2011-11-24 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2011-11-07 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code