Consider this test case:
-------8<-------
{$mode ObjFPC}
// EXPECTED: 'Error: Identifier not found "result"'
// ACTUAL BUG #1: gets compiled
operator - (const L, R: Char) returned: Char;
begin
result := 'Z'
end;
// EXPECTED: gets compiled
// ACTUAL BUG #2: 'Error: Duplicate identifier "result"'
operator / (const L, R: Char) result: Char;
begin
result := 'Z'
end;
begin
end.
-------8<-------
The patch http://hg.blaise.ru/public/fpc/rev/ce20f68924a0 (attached) alters insert_funcret_local:
1) Extracts duplicate code into alias_funcret;
2) Avoids the second call to the pd.resultname getter;
3) Avoids copying strings pd.resultname^/pd.procsym.name to the local buffer hs;
4) Fixes the first bug: the alias Result should not be implicitly declared when another identifier is declared as the return value;
5) Fixes the second bug: even with {$modeswitch result+}, it should be possible to explicitly name a return value Result.
NB: The patch preserves the current suspicious behaviour of not slapping vo_is_result onto explicit names. More on that later.If needed, I can file a bug report to document the user-visible change in behaviour.
