Browse Source

* Parse 'variant_expression.ident[parameters]' as a parametrized property access, rather than non-parametrized property followed by array subscript. This corresponds to Delphi behavior and fixes Mantis #17127.
* Fixed the related test: Excel Worksheet interface does not have a default property.

git-svn-id: trunk@16864 -

sergei 14 years ago
parent
commit
71cce9716d
2 changed files with 15 additions and 3 deletions
  1. 14 2
      compiler/pexpr.pas
  2. 1 1
      packages/winunits-base/tests/testcom1.pp

+ 14 - 2
compiler/pexpr.pas

@@ -1858,6 +1858,7 @@ implementation
             stack space }
           dispatchstring : ansistring;
           nodechanged    : boolean;
+          calltype: tdispcalltype;
         label
           skipreckklammercheck;
         begin
@@ -2080,15 +2081,26 @@ implementation
                        variantdef:
                          begin
                            { dispatch call? }
+                           { lhs := v.ident[parameters] -> property get
+                             lhs := v.ident(parameters) -> method call
+                             v.ident[parameters] := rhs -> property put
+                             v.ident(parameters) := rhs -> also property put }
                            if token=_ID then
                              begin
                                dispatchstring:=orgpattern;
                                consume(_ID);
+                               calltype:=dct_method;
                                if try_to_consume(_LKLAMMER) then
                                  begin
                                    p2:=parse_paras(false,true,_RKLAMMER);
                                    consume(_RKLAMMER);
                                  end
+                               else if try_to_consume(_LECKKLAMMER) then
+                                 begin
+                                   p2:=parse_paras(false,true,_RECKKLAMMER);
+                                   consume(_RECKKLAMMER);
+                                   calltype:=dct_propget;
+                                 end
                                else
                                  p2:=nil;
                                { property setter? }
@@ -2105,9 +2117,9 @@ implementation
                                { this is only an approximation
                                  setting useresult if not necessary is only a waste of time, no more, no less (FK) }
                                if afterassignment or in_args or (token<>_SEMICOLON) then
-                                 p1:=translate_disp_call(p1,p2,dct_method,dispatchstring,0,cvarianttype)
+                                 p1:=translate_disp_call(p1,p2,calltype,dispatchstring,0,cvarianttype)
                                else
-                                 p1:=translate_disp_call(p1,p2,dct_method,dispatchstring,0,voidtype);
+                                 p1:=translate_disp_call(p1,p2,calltype,dispatchstring,0,voidtype);
                              end
                            else { Error }
                              Consume(_ID);

+ 1 - 1
packages/winunits-base/tests/testcom1.pp

@@ -19,7 +19,7 @@ begin
   For I:=1 to 5 do
     For J:=1 to 5 do
       begin
-      Cells:=ActiveSheet[I,J];
+      Cells:=ActiveSheet.Cells[I,J];
       Cells.Value:=I+J;
       end;
 end.