diff --git a/.gitattributes b/.gitattributes index f9c07611fc..4e661d0f5d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8636,6 +8636,7 @@ tests/webtbf/tw1407.pp svneol=native#text/plain tests/webtbf/tw14104a.pp svneol=native#text/plain tests/webtbf/tw14104b.pp svneol=native#text/plain tests/webtbf/tw14104c.pp svneol=native#text/plain +tests/webtbf/tw14248.pp svneol=native#text/plain tests/webtbf/tw1432.pp svneol=native#text/plain tests/webtbf/tw1467.pp svneol=native#text/plain tests/webtbf/tw1483.pp svneol=native#text/plain diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index c91540184e..2f967dc904 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1339,6 +1339,8 @@ implementation { Access to funcret or need to call the function? } if (srsym.typ in [absolutevarsym,localvarsym,paravarsym]) and (vo_is_funcret in tabstractvarsym(srsym).varoptions) and + { result(x) is not allowed } + not(vo_is_result in tabstractvarsym(srsym).varoptions) and ( (token=_LKLAMMER) or ( @@ -1346,8 +1348,7 @@ implementation (m_tp7 in current_settings.modeswitches) or (m_delphi in current_settings.modeswitches) ) and - (afterassignment or in_args) and - not(vo_is_result in tabstractvarsym(srsym).varoptions) + (afterassignment or in_args) ) ) then begin diff --git a/tests/webtbf/tw14248.pp b/tests/webtbf/tw14248.pp new file mode 100644 index 0000000000..75edf26a47 --- /dev/null +++ b/tests/webtbf/tw14248.pp @@ -0,0 +1,14 @@ +{ %fail } +program Project1; +{$mode objfpc}{$H+} + +function Foo(a: Integer): Integer; +begin + dec(a); + if a < 0 then exit; + Result := Result(a); +end; + +begin + Foo(10); +end.