diff --git a/.gitattributes b/.gitattributes index 7f4a3d7925..e52ed0f0e6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12567,6 +12567,7 @@ tests/webtbs/tw2178.pp svneol=native#text/plain tests/webtbs/tw2185.pp svneol=native#text/plain tests/webtbs/tw2186.pp svneol=native#text/plain tests/webtbs/tw2187.pp svneol=native#text/plain +tests/webtbs/tw21878.pp svneol=native#text/plain tests/webtbs/tw2196.pp svneol=native#text/plain tests/webtbs/tw2197.pp svneol=native#text/plain tests/webtbs/tw2198.pp svneol=native#text/plain diff --git a/compiler/ninl.pas b/compiler/ninl.pas index 0b401bc650..fb28463dcd 100644 --- a/compiler/ninl.pas +++ b/compiler/ninl.pas @@ -1599,8 +1599,10 @@ implementation while assigned(ppn.right) do begin inc(counter); + set_varstate(ppn.left,vs_read,[vsf_must_be_valid]); ppn:=tcallparanode(ppn.right); end; + set_varstate(ppn.left,vs_read,[vsf_must_be_valid]); paradef:=ppn.left.resultdef; if is_ansistring(paradef) then // set resultdef to argument def diff --git a/tests/webtbs/tw21878.pp b/tests/webtbs/tw21878.pp new file mode 100644 index 0000000000..e2fca6a58c --- /dev/null +++ b/tests/webtbs/tw21878.pp @@ -0,0 +1,23 @@ +{ %norun } +{ %opt=-vn -Sen } + +{$mode objfpc}{$H+} + +uses + Classes, SysUtils; + +function DoSomething(const AName: string): integer; +var + i, l: Integer; +begin + Result := 0;; + l := Length(AName); + for i:= 1 to Paramcount do begin + if copy(ParamStr(i),1, l) = AName then + inc(Result); + end; +end; + +begin + DoSomething('a'); +end.