bugGNU Octave - Bugs: bug #42152, Overloaded vercat() not called in...

 
 

bug #42152: Overloaded vercat() not called in some other cases

Submitted by:  Colin Macdonald <cbm>
Submitted on:  Sun 20 Apr 2014 03:56:53 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Mon 22 May 2017 11:06:26 PM UTC, comment #3:

That should have been "@double/horzcat" in my second bullet point.

Actually creating a @double/horzcat.m function with the following body

actually fixes this issue completely. Because the method can be resolved, the class concatenation can succeed on the non-class double type, and the resulting class array is finished correctly.

I would characterize this bug slightly differently than the current summary, instead of the fact that the overloaded vertcat method is not being called, it's more accurate to say that class-based concatenation of a row of primitive types fails because the builtin cat methods are not looked up properly in a class context.

Mike Miller <mtmiller>
Project Administrator
Mon 22 May 2017 10:31:47 PM UTC, comment #2:

I've started digging into this bug. Some notes so far:

  • The syntax "[x; [1 2]]" is understood by the parser as three separate concatenation operations. First, a 1×2 concatenation of the second row, consisting entirely of 1×1 doubles, which results in a double row vector. Second, a "vertcat" concatenation of the class value "x" with the double array [1 2]. And third, the nested "vertcat" concatenation of double arrays that happens inside the overloaded "vertcat" method of the A class.
  • The syntax "[x; 1 2]" is understood by the parser as a single concatenation operation which fails, as we know. The difference is the concatenation is being done on the rows of the matrix as an overall class type, rather than being done separately on the second row as a double type. Since the result type is expected to be a class, the function do_class_concat is called on each row. When do_class_concat gets a row that is entirely scalar doubles, it doesn't know what to do with them and the error is thrown (at libinterp/corefcn/data.cc line 1742). The conversion code assumes that because there is no @double/vertcat method explicitly defined, it must try to convert these objects to structs and concatenate them.

So this seems like a circular limitation, in that we do have a way to call vertcat on a list of doubles, but it is not recognized as a class method, so the class concatenation code can't operate on doubles.

Mike Miller <mtmiller>
Project Administrator
Wed 23 Jul 2014 03:24:34 PM UTC, comment #1:

I hit this again, so spent a little time on it... Sorry no fix, but here's the test at least.

Its a patch to classes.tst to exhibits this on the Snork class. The failures are marked with xtest, following what I saw in Bug #38128.

(file #31764)

Colin Macdonald <cbm>
Sun 20 Apr 2014 03:56:53 PM UTC, original submission:

x is a member of a class with a overloading vertcat.

For details, look at bug #38128, consider the example given there in the OP. Those do work correctly.

The error message is:

I attach the files for the class, essentially from bug #38128 with typo fixed and double.m added.

Colin Macdonald <cbm>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #31764:  bug42152.diff added by cbm (2KiB - text/x-patch)
file #31219:  A.m added by cbm (60B - text/x-objcsrc)
file #31220:  vertcat.m added by cbm (62B - text/x-objcsrc)
file #31221:  double.m added by cbm (35B - text/x-objcsrc)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by cbm (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 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 22 May 2017 11:06:26 PM UTCmtmillerStatusNone=>Confirmed
    Wed 09 Sep 2015 11:49:44 PM UTCmtmillerDependencies-=>bugs #45904 is dependent
    Sat 04 Jul 2015 01:27:42 PM UTCcarandraugDependencies-=>bugs #45423 is dependent
    Wed 23 Jul 2014 03:24:34 PM UTCcbmAttached File-=>Added bug42152.diff, #31764
    Sun 20 Apr 2014 03:56:53 PM UTCcbmAttached File-=>Added A.m, #31219
      Attached File-=>Added vertcat.m, #31220
      Attached File-=>Added double.m, #31221

    Back to the top


    Powered by Savane 3.1-cleanup1