mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 18:29:27 +02:00
* automatically try to call procvars that are subscripted or used in a
with-statement, both in FPC and TP/Delphi modes (mantis #15728) git-svn-id: trunk@14881 -
This commit is contained in:
parent
1b58fcc877
commit
d60e1f674c
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -10281,6 +10281,7 @@ tests/webtbs/tw1567.pp svneol=native#text/plain
|
||||
tests/webtbs/tw15690.pp svneol=native#text/plain
|
||||
tests/webtbs/tw15693.pp svneol=native#text/plain
|
||||
tests/webtbs/tw15694.pp svneol=native#text/plain
|
||||
tests/webtbs/tw15728.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1573.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1592.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1617.pp svneol=native#text/plain
|
||||
|
@ -2028,6 +2028,10 @@ implementation
|
||||
p1:=cderefnode.create(p1);
|
||||
do_typecheckpass(p1);
|
||||
end;
|
||||
{ procvar.<something> can never mean anything so always
|
||||
try to call it in case it returns a record/object/... }
|
||||
maybe_call_procvar(p1,false);
|
||||
|
||||
case p1.resultdef.typ of
|
||||
recorddef:
|
||||
begin
|
||||
|
@ -548,6 +548,10 @@ implementation
|
||||
if (p.nodetype=vecn) and
|
||||
(nf_memseg in p.flags) then
|
||||
CGMessage(parser_e_no_with_for_variable_in_other_segments);
|
||||
|
||||
{ "with procvar" can never mean anything, so always try
|
||||
to call it in case it returns a record/object/... }
|
||||
maybe_call_procvar(p,false);
|
||||
|
||||
if (p.resultdef.typ in [objectdef,recorddef,classrefdef]) then
|
||||
begin
|
||||
|
35
tests/webtbs/tw15728.pp
Normal file
35
tests/webtbs/tw15728.pp
Normal file
@ -0,0 +1,35 @@
|
||||
program TT;
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
type
|
||||
t_R = record
|
||||
R1:integer;
|
||||
end;
|
||||
|
||||
t_X = function:t_R;
|
||||
|
||||
function A:t_R;
|
||||
begin
|
||||
Result.R1:=123;
|
||||
end;
|
||||
|
||||
var X:t_X;
|
||||
|
||||
begin
|
||||
X:=A;
|
||||
if x.r1<>123 then
|
||||
halt(1);
|
||||
writeln(X.R1); // Error: Illegal qualifier
|
||||
writeln(X().R1); // OK
|
||||
with X do
|
||||
begin
|
||||
if r1<>123 then
|
||||
halt(2);
|
||||
writeln(R1); //Error: Expression type must be class or record
|
||||
end;
|
||||
with X() do writeln(R1); // OK
|
||||
end.
|
Loading…
Reference in New Issue
Block a user