bugGNU Octave - Bugs: bug #34478, argn is undefined inside subsref


bug #34478: argn is undefined inside subsref

Submitted by:  Carnë Draug <carandraug>
Submitted on:  Tue 04 Oct 2011 06:49:30 PM UTC  
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: Wont FixAssigned to: None
Originator Name: Open/Closed: Closed
Release: 3.4.2Operating System: GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

Sat 30 Jul 2016 08:24:57 PM UTC, comment #7:

I don't even remember why I needed argn within subsref (considering the timing I was probably trying to workaround lack of classdef to implement inputParser for the general package).

I no longer have a use case for this and seems like no one else has ever had an issue with it either. Your reasoning about subsref not really be called by the user makes sense too. So yeah, closed as won't fix.

I see that you already opened the unrelated bug about nargout as bug #48656

Carnë Draug <carandraug>
Project Member
Thu 28 Jul 2016 09:16:03 PM UTC, comment #6:

I think the reason that argn is not defined is because when you use the indexing operators, subsref is called internally on your behalf, you are not calling it directly. The argument strings that are normally passed in argn must be stored by the parser when a function is called, and are not available in this case.

With carandraug's original example code:

To work around this the octave_class methods that dispatch to the m-file functions would have to somehow forward the literal argument strings on to the m-file function. I don't know that this is worth trying to solve or even desirable.

This same lack of argument strings would apply to any other class methods that are not called directly by the user.

Close as won't fix?

Mike Miller <mtmiller>
Project Administrator
Thu 28 Jul 2016 09:01:48 PM UTC, comment #5:

Sorry for the noise, I am unsure about the original argn problem, but I think nargout being wrong is a completely different bug.

Mike Miller <mtmiller>
Project Administrator
Thu 28 Jul 2016 06:48:52 PM UTC, comment #4:

Just hit this error and found this open bug report. This is due to this chunk of code: http://hg.savannah.gnu.org/hgweb/octave/file/829e0aafebdc/libinterp/octave-value/ov-class.cc#l437

Does anyone know what Matlab compatibility this is attempting to deal with? Blame points me to these two changes


So it's the way that the @foo/subsref.m function is called by octave_class that is to blame, but I don't understand what this is meant to be doing to attempt to fix it.

It looks like it's setting up a heuristic for what kinds of indexing could lead to more return values than the caller actually requested, maybe? Is this even needed now?

Mike Miller <mtmiller>
Project Administrator
Tue 14 Jan 2014 01:13:59 AM UTC, comment #3:

attached source code of example

(file #30267)

Felipe G. Nievinski <fgnievinski>
Tue 14 Jan 2014 01:06:55 AM UTC, comment #2:

likely related: nargout silently fails.

with @aclass/subsref.m as follows:

I find, correctly:


but, incorrectly:

and also:

Felipe G. Nievinski <fgnievinski>
Thu 06 Oct 2011 10:57:52 AM UTC, comment #1:


just for the record, replacing argn with

b = _varval_ (".argn.");

on subsref.m still causes an error about not being defined. Here's the exact error:

Carnë Draug <carandraug>
Project Member
Tue 04 Oct 2011 06:49:30 PM UTC, original submission:


I was trying to implement a new class and found that when calling argn inside subsref, it is not defined (note that this also causes inputname to fail inside subsref).

I uploaded a file with the most minimal case to replicate this behaviour. There's only the class constructor and the subsref function which only checks argn.

The following code will fail now with:

> a = testClass;
> a.method

error: `argn' undefined near line 2 column 3
error: called from:
error: /home/carandraug/development/inputParser/@testClass/subsref.m at line 2, column 3

And I'm using octave 3.4.2 in Debian Squeeze (not the one in the repos, compiled by me).

Carnë Draug <carandraug>
Project Member


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

Attach File(s):

Attached Files
file #30267:  @aclass.zip added by fgnievinski (478B - application/x-zip-compressed)
file #24098:  @testClass.tar added by carandraug (10KiB - application/x-tar)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by fgnievinski (Posted a comment)
  • -unavailable- added by carandraug (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 30 Jul 2016 08:24:57 PM UTCcarandraugOpen/ClosedOpen=>Closed
    Thu 28 Jul 2016 09:16:03 PM UTCmtmillerStatusNone=>Wont Fix
    Tue 14 Jan 2014 01:13:59 AM UTCfgnievinskiAttached File-=>Added @aclass.zip, #30267
    Tue 04 Oct 2011 06:49:30 PM UTCcarandraugAttached File-=>Added @testClass.tar, #24098

    Back to the top

    Powered by Savane 3.1-cleanup1