Skip to main content

validate_single_return

Function validate_single_return 

Source
pub fn validate_single_return(
    source: &str,
    _tree: &Tree,
    fn_node: &Node<'_>,
    lang: LangId,
) -> Result<(), usize>
Expand description

Validate that a function has at most one return statement (suitable for inlining).

  • Arrow functions with expression bodies (no return keyword) → valid (single-return)
  • Functions with 0 returns (void) → valid
  • Functions with exactly 1 return → valid
  • Functions with >1 return → invalid, returns the count