From 71cce9716db8a80865fb529bd10953bd1a9c1659 Mon Sep 17 00:00:00 2001 From: sergei Date: Wed, 2 Feb 2011 09:11:11 +0000 Subject: [PATCH] * 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 - --- compiler/pexpr.pas | 16 ++++++++++++++-- packages/winunits-base/tests/testcom1.pp | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 3f2049eb67..b4438306e2 100644 --- a/compiler/pexpr.pas +++ b/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); diff --git a/packages/winunits-base/tests/testcom1.pp b/packages/winunits-base/tests/testcom1.pp index 5739bf7143..c7b4884400 100644 --- a/packages/winunits-base/tests/testcom1.pp +++ b/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.