Skip to content

STY003 function-missing-result ​

warning opt-in

A function has no result(...) clause.

Why ​

Without result the function's name is also its result variable: inside the function, f is the value, and a recursive call or a reference to the function as a procedure needs other syntax. A named result (result(r)) separates the two and reads unambiguously.

Reported ​

fortran
function norm2d(x, y)

Preferred ​

fortran
function norm2d(x, y) result(r)

Suppressing ​

For one occurrence, with the reason on the same line (or alone on the line before the statement):

fortran
! fobis: ignore[STY003] <why this occurrence is fine>

For the whole project, ignore = STY003 in the fobos [lint] section.

Equivalent ​

Fortitude rule S221 (see Lint Rules).