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 -> (\declaration scopes ->
case Node.value declaration of case Node.value declaration of
Expression.LetFunction function -> Expression.LetFunction function ->
registerVariable let
{ variableType = LetVariable { name, expression, arguments } =
, node = (Node.value function.declaration).name Node.value function.declaration
}
scopes 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 _ _ -> Expression.LetDestructuring _ _ ->
scopes scopes

View File

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