Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi Prism/Compiler    [ Add a report in this area ]  
Report #:  98598   Status: Open
Can't use certain array types between assemblies
Project:  Embarcadero Prism Build #:  5.0.29.893
Version:    2010.1 Submitted By:   Robert Ogren
Report Type:  Basic functionality failure Date Reported:  9/6/2011 4:36:55 AM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   287484
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
The compiler seems to generate incorrect code when using certain array types between assemblies.
Code similar to the following, which worked fine with the Spring 2011 release, produces a runtime error when compiled with XE2 (Oxygene version 5.0.29.893).

Put the following in a class library:

type
  TableLayoutMatrix = array[0.., 0..] of string;

  TableLayout = public class    
  public    
    property Table: TableLayoutMatrix;
  end;

Put the following in the main method of an empty console application and add a reference to the class library.

class method ConsoleApp.Main(args: array of String);
var
  tl: TableLayout;
begin
  tl := new TableLayout;

  if Assigned(tl.Table) then
    Console.WriteLine('Table property is assigned')
  else
    Console.WriteLine('Table property is not assigned');
end;


The code compiles without problem, but at runtime, the program fails with a MissingMethodException
Method not found: 'System.String[,] ModoptLib1.TableLayout.get_Table()'.


According to Reflector the call to get the property seems to have an extra modopt that causes the method to not be found.

callvirt instance string[,] modopt(<PublicImplementationDetails>/array$2$0,0$$) modopt([ModoptLib1]<PublicImplementationDetails>/array$2$0,0$$) [ModoptLib1]ModoptLib1.TableLayout::get_Table()

Types such as plain array of string and array[5..] of string seems to work OK.

Steps to Reproduce:
Compile and run the attached solution with a class library and a console application. You should get an error at runtime even though the program compiles OK.
Workarounds
Use simpler array types such as array of array of string to create a multidimensional array
Attachment
Modopt1.zip
Comments

None

Server Response from: ETNACODE01