Re: cleaning perl code

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: cleaning perl code
Дата
Msg-id 19843.1586623730@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: cleaning perl code  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Ответы Re: cleaning perl code
Список pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
> On 4/11/20 12:30 AM, Noah Misch wrote:
>> In summary, among those warnings, I see non-negative value in "Code before
>> warnings are enabled" only.  While we're changing this, I propose removing
>> Subroutines::RequireFinalReturn.  Implicit return values were not a material
>> source of PostgreSQL bugs, yet we've allowed this to litter our code:

> That doesn't mean it won't be a source of problems in future, I've
> actually been bitten by this in the past.

Yeah, as I recall, the reason for the restriction is that if you fall out
without a "return", what's returned is the side-effect value of the last
statement, which might be fairly surprising.  Adding explicit "return;"
guarantees an undef result.  So when this does prevent a bug it could
be a pretty hard-to-diagnose one.  The problem is that it's a really
verbose/pedantic requirement for subs that no one ever examines the
result value of.

Is there a way to modify the test so that it only complains when
the final return is missing and there are other return(s) with values?
That would seem like a more narrowly tailored check.

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: cleaning perl code
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: range_agg