Hi,
Is this an expected behaviors?
total variable, I get the error of "CIRCULAR DEFINITION", the variables cannot conflict though. total =
[]
|> List.walk { total: "" } \{ total }, _ ->
{ total }
List.walk I want to |> .total, I can't find how the indent it. The compiler always think I'm still in the List.walk callback. res =
[]
|> List.walk { total: "" } \{ total }, _ ->
{ total }
|> .total
Regarding #2, what happens if you put parentheses around your function?
Parentheses often fix scope/indentation issues for me
For the first, that error happens because Roc does not allow variable shadowing, and total is shadowed in the inner lambda. That error message should be made better though.
In my mind, the variable did not exist before the assignement (total =)
I didn't see it as shadowing
it is this way because “total” could be defined as recursive, that is, you could do something like “total = \_ -> total {}”
Last updated: Dec 21 2025 at 12:15 UTC