Fix let function arguments not registering with the correct module name

This commit is contained in:
Jeroen Engels 2023-06-17 19:47:43 +02:00
parent 84aae3b64b
commit 929d8508fd
2 changed files with 31 additions and 5 deletions

View File

@ -1220,11 +1220,28 @@ expressionEnterVisitor node context =
(\declaration scopes ->
case Node.value declaration of
Expression.LetFunction function ->
registerVariable
{ variableType = LetVariable
, node = (Node.value function.declaration).name
}
scopes
let
{ name, expression, arguments } =
Node.value function.declaration
withLetVariable : NonEmpty Scope
withLetVariable =
registerVariable
{ variableType = LetVariable
, node = name
}
scopes
in
if List.isEmpty arguments then
withLetVariable
else
let
names : Dict String VariableInfo
names =
collectNamesFromPattern PatternVariable arguments Dict.empty
in
NonEmpty.mapHead (\scope -> { scope | cases = ( expression, names ) :: scope.cases }) withLetVariable
Expression.LetDestructuring _ _ ->
scopes

View File

@ -93,6 +93,10 @@ a = localValue
True
Just
Cmd.none
(let foo get = get
in
get
)
(+)
(117 + 3)
(<?>)
@ -155,6 +159,8 @@ Http.get -> Http.get
<nothing>.True -> Basics.True
<nothing>.Just -> Maybe.Just
Cmd.none -> Platform.Cmd.none
<nothing>.get -> <nothing>.get
<nothing>.get -> Http.get
<nothing>.+ -> Basics.+
<nothing>.+ -> Basics.+
<nothing>.<?> -> Url.Parser.<?>
@ -689,6 +695,9 @@ collectPatterns lookupFunction context node =
Pattern.AsPattern subPattern _ ->
collectPatterns lookupFunction context subPattern
Pattern.VarPattern _ ->
[]
_ ->
Debug.todo ("Other patterns in case expressions are not handled: " ++ Debug.toString node)