* don't allow skipping property parameters if the getter/setter has default

parameters (mantis #13956)
  * when reporting an error about too few specified parameters to a call,
    return the column of the call itself rather than after the last parameter
    (because this ends up after the end of an indexed property in case of
     properties, which is confusing)

git-svn-id: trunk@13326 -
This commit is contained in:
Jonas Maebe 2009-06-26 17:31:41 +00:00
parent 5c006b9b86
commit e42842b31c
4 changed files with 42 additions and 12 deletions

1
.gitattributes vendored
View File

@ -8605,6 +8605,7 @@ tests/webtbf/tw13563a.pp svneol=native#text/plain
tests/webtbf/tw1365.pp svneol=native#text/plain
tests/webtbf/tw13815.pp svneol=native#text/plain
tests/webtbf/tw1395.pp svneol=native#text/plain
tests/webtbf/tw13956.pp svneol=native#text/plain
tests/webtbf/tw13992.pp svneol=native#text/plain
tests/webtbf/tw1407.pp svneol=native#text/plain
tests/webtbf/tw1432.pp svneol=native#text/plain

View File

@ -68,10 +68,10 @@ interface
FAllowVariant : boolean;
procedure collect_overloads_in_class(ProcdefOverloadList:TFPObjectList);
procedure collect_overloads_in_units(ProcdefOverloadList:TFPObjectList);
procedure create_candidate_list(ignorevisibility:boolean);
procedure create_candidate_list(ignorevisibility,allowdefaultparas:boolean);
function proc_add(ps:tprocsym;pd:tprocdef):pcandidate;
public
constructor create(sym:tprocsym;st:TSymtable;ppn:tnode;ignorevisibility:boolean);
constructor create(sym:tprocsym;st:TSymtable;ppn:tnode;ignorevisibility,allowdefaultparas:boolean);
constructor create_operator(op:ttoken;ppn:tnode);
destructor destroy;override;
procedure list(all:boolean);
@ -1613,7 +1613,7 @@ implementation
TCallCandidates
****************************************************************************}
constructor tcallcandidates.create(sym:tprocsym;st:TSymtable;ppn:tnode;ignorevisibility:boolean);
constructor tcallcandidates.create(sym:tprocsym;st:TSymtable;ppn:tnode;ignorevisibility,allowdefaultparas:boolean);
begin
if not assigned(sym) then
internalerror(200411015);
@ -1621,7 +1621,7 @@ implementation
FProcsym:=sym;
FProcsymtable:=st;
FParanode:=ppn;
create_candidate_list(ignorevisibility);
create_candidate_list(ignorevisibility,allowdefaultparas);
end;
@ -1631,7 +1631,7 @@ implementation
FProcsym:=nil;
FProcsymtable:=nil;
FParanode:=ppn;
create_candidate_list(false);
create_candidate_list(false,false);
end;
@ -1744,7 +1744,7 @@ implementation
end;
procedure tcallcandidates.create_candidate_list(ignorevisibility:boolean);
procedure tcallcandidates.create_candidate_list(ignorevisibility,allowdefaultparas:boolean);
var
j : integer;
pd : tprocdef;
@ -1803,8 +1803,17 @@ implementation
it is visible }
if (FParalength>=pd.minparacount) and
(
(FParalength<=pd.maxparacount) or
(po_varargs in pd.procoptions)
(
allowdefaultparas and
(
(FParalength<=pd.maxparacount) or
(po_varargs in pd.procoptions)
)
) or
(
not allowdefaultparas and
(FParalength=pd.maxparacount)
)
) and
(
ignorevisibility or

View File

@ -2330,7 +2330,7 @@ implementation
{ ignore possible private for properties or in delphi mode for anon. inherited (FK) }
ignorevisibility:=(nf_isproperty in flags) or
((m_delphi in current_settings.modeswitches) and (cnf_anon_inherited in callnodeflags));
candidates:=tcallcandidates.create(symtableprocentry,symtableproc,left,ignorevisibility);
candidates:=tcallcandidates.create(symtableprocentry,symtableproc,left,ignorevisibility,not(nf_isproperty in flags));
{ no procedures found? then there is something wrong
with the parameter size or the procedures are
@ -2369,9 +2369,7 @@ implementation
end
else
begin
if assigned(left) then
current_filepos:=left.fileinfo;
CGMessage1(parser_e_wrong_parameter_size,symtableprocentry.realname);
CGMessagePos1(fileinfo,parser_e_wrong_parameter_size,symtableprocentry.realname);
symtableprocentry.write_parameter_lists(nil);
end;
end;

22
tests/webtbf/tw13956.pp Normal file
View File

@ -0,0 +1,22 @@
{ %fail }
{$ifdef fpc}
{$mode objfpc}{$H+}
{$endif}
type
{ TForm1 }
TForm1 = class
private
function GetFoo(Index: Integer; Ask: Boolean = True): Integer;
public
property Foo[Index: Integer; Ask: Boolean]: Integer read GetFoo;
end;
function TForm1.GetFoo(Index: Integer; Ask: Boolean): Integer;
begin
Result := Foo[Index];
end;
begin
end.