Skip to content

Commit

Permalink
Use an underscore to avoid collision with fnArg
Browse files Browse the repository at this point in the history
  • Loading branch information
miniBill committed May 30, 2024
1 parent 08621c4 commit 4a1523c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
8 changes: 4 additions & 4 deletions cli/gen-package/codegen/Gen/Elm/Declare.elm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn :
-> Elm.Expression
-> (Elm.Expression -> Elm.Expression)
-> Elm.Expression
fn fnArg fnArg0 fnArg1 =
fn fn_Arg fn_Arg0 fn_Arg1 =
Elm.apply
(Elm.value
{ importFrom = [ "Elm", "Declare" ]
Expand Down Expand Up @@ -54,7 +54,7 @@ fn fnArg fnArg0 fnArg1 =
)
}
)
[ Elm.string fnArg, fnArg0, Elm.functionReduced "fnUnpack" fnArg1 ]
[ Elm.string fn_Arg, fn_Arg0, Elm.functionReduced "fnUnpack" fn_Arg1 ]


{-| fn2:
Expand Down Expand Up @@ -1340,7 +1340,7 @@ call_ :
}
call_ =
{ fn =
\fnArg fnArg0 fnArg1 ->
\fn_Arg fn_Arg0 fn_Arg1 ->
Elm.apply
(Elm.value
{ importFrom = [ "Elm", "Declare" ]
Expand Down Expand Up @@ -1376,7 +1376,7 @@ call_ =
)
}
)
[ fnArg, fnArg0, fnArg1 ]
[ fn_Arg, fn_Arg0, fn_Arg1 ]
, fn2 =
\fn2Arg fn2Arg0 fn2Arg1 fn2Arg2 ->
Elm.apply
Expand Down
14 changes: 7 additions & 7 deletions cli/gen-package/codegen/Gen/Elm/Let.elm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn :
-> (Elm.Expression -> Elm.Expression)
-> Elm.Expression
-> Elm.Expression
fn fnArg fnArg0 fnArg1 fnArg2 =
fn fn_Arg fn_Arg0 fn_Arg1 fn_Arg2 =
Elm.apply
(Elm.value
{ importFrom = [ "Elm", "Let" ]
Expand Down Expand Up @@ -203,10 +203,10 @@ fn fnArg fnArg0 fnArg1 fnArg2 =
)
}
)
[ Elm.string fnArg
, fnArg0
, Elm.functionReduced "fnUnpack" fnArg1
, fnArg2
[ Elm.string fn_Arg
, fn_Arg0
, Elm.functionReduced "fnUnpack" fn_Arg1
, fn_Arg2
]


Expand Down Expand Up @@ -622,7 +622,7 @@ call_ =
)
[ recordArg, recordArg0, recordArg1 ]
, fn =
\fnArg fnArg0 fnArg1 fnArg2 ->
\fn_Arg fn_Arg0 fn_Arg1 fn_Arg2 ->
Elm.apply
(Elm.value
{ importFrom = [ "Elm", "Let" ]
Expand Down Expand Up @@ -671,7 +671,7 @@ call_ =
)
}
)
[ fnArg, fnArg0, fnArg1, fnArg2 ]
[ fn_Arg, fn_Arg0, fn_Arg1, fn_Arg2 ]
, fn2 =
\fn2Arg fn2Arg0 fn2Arg1 fn2Arg2 fn2Arg3 ->
Elm.apply
Expand Down
19 changes: 14 additions & 5 deletions cli/gen-package/src/Generate.elm
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ block2Maker thisModule block =
)
|> Gen.Elm.record
in
Elm.fn (Elm.Arg.varWith (name ++ "_Arg") lambdaArgType) lambdaValue
Elm.fn (Elm.Arg.varWith (toArgName name) lambdaArgType) lambdaValue
|> Just

_ ->
Expand Down Expand Up @@ -534,7 +534,7 @@ annotationNamed thisModule name tags =
Elm.function
(List.indexedMap
(\i arg ->
( name ++ "_Arg" ++ String.fromInt i
( toArgName name ++ String.fromInt i
, Just (Annotation.named elmAnnotation "Annotation")
)
)
Expand Down Expand Up @@ -630,7 +630,7 @@ aliasNamed docAlias =
Elm.function
(List.indexedMap
(\i arg ->
( docAlias.name ++ "_Arg" ++ String.fromInt i
( toArgName docAlias.name ++ String.fromInt i
, Just (Annotation.named elmAnnotation "Annotation")
)
)
Expand Down Expand Up @@ -884,7 +884,7 @@ captureFunction baseName tipe captured =
in
captureFunction baseName
two
{ arguments = ( baseName ++ "_Arg", Just unpacked.annotation ) :: captured.arguments
{ arguments = ( toArgName baseName, Just unpacked.annotation ) :: captured.arguments
, unpackers = unpacked.unpacker :: captured.unpackers
}

Expand All @@ -893,11 +893,20 @@ captureFunction baseName tipe captured =
unpacked =
unpackArg baseName tipe
in
{ arguments = ( baseName ++ "_Arg", Just unpacked.annotation ) :: captured.arguments
{ arguments = ( toArgName baseName, Just unpacked.annotation ) :: captured.arguments
, unpackers = unpacked.unpacker :: captured.unpackers
}


toArgName : String -> String
toArgName baseName =
if baseName == "fn" then
"fn_Arg"

else
baseName ++ "Arg"


unpackArgForLambdas :
String
-> Elm.Type.Type
Expand Down

0 comments on commit 4a1523c

Please sign in to comment.