calculateFunctionArity

Calculates the arity (function.length). Per spec the length property counts only the parameters before the first one with a default value, and rest parameters do not count at all.

Ref: ECMA 2026, 15.1.5 Static Semantics: ExpectedArgumentCount