E4006

E4006#

This error occurs when the same local function name is declared multiple times in a local recursive function group. Each function in the group must have a unique name.

Erroneous Example#

pub fn use_helper() -> Int {
  letrec helper = fn(n : Int) -> Int {
    n
  } and helper = fn(n : Int) -> Int {
    n + 1
  }
  helper(0)
}

Suggestion#

To fix this error, give each local function in the recursive group a unique name:

pub fn () ->  {
  letrec  = fn( : ) ->  {
    
  } and  = fn( : ) ->  {
     + 1
  }
  ((0))
}

You can also move one of the functions to a different scope or merge the functionality into a single function if they serve similar purposes.