Skip to content

Commit

Permalink
Fixes Fix does not take aliases into account gampleman#16 (gampleman#19)
Browse files Browse the repository at this point in the history
It's fun when you can fix a bug purely by deleting code... But in this
case we were doing the same job twice - once in code generation and the
second time in post-processing. I've now removed the part that happens
during codegen so that the post-processing can do its job correctly.
  • Loading branch information
gampleman authored Oct 4, 2024
1 parent 807dfd7 commit 4eb5a4b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/Internal/ResolvedType.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ refToExpr currentModule imports ref =

else
case List.Extra.find (\import_ -> import_.moduleName == ref.modulePath) imports of
Just { moduleAlias, exposingList } ->
Just { exposingList } ->
if isExposed exposingList ref.name then
Elm.CodeGen.fun ref.name

else
case moduleAlias of
Just moduleAlias_ ->
Elm.CodeGen.fqFun [ moduleAlias_ ] ref.name

Nothing ->
Elm.CodeGen.fqFun ref.modulePath ref.name
Elm.CodeGen.fqFun ref.modulePath ref.name

Nothing ->
Elm.CodeGen.fqFun ref.modulePath ref.name
Expand Down
36 changes: 35 additions & 1 deletion tests/FuzzerCodeGenTest.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module FuzzerCodeGenTest exposing (suite)

import CodeGenerator.Test exposing (FakeDependency, codeGenTest)
import CodeGenerator.Test exposing (FakeDependency, codeGenIncrementalTest, codeGenTest)
import StandardModule
import Test exposing (Test, describe)

Expand Down Expand Up @@ -109,5 +109,39 @@ bFuzzer =
(Fuzz.map Dict.fromList (Fuzz.list (Fuzz.pair Fuzz.string Fuzz.niceFloat)))
(Fuzz.pair (Fuzz.maybe Fuzz.string) Fuzz.bool)
(Fuzz.map2 (\\a b -> { a = a, b = b }) Fuzz.int Fuzz.int)
"""
, codeGenIncrementalTest "Issue #16"
[ elmJson ]
[]
[ """module SQLite.Statement.CreateTable exposing (ColumnConstraint(..), InnerColumnConstraint(..))
type alias ColumnConstraint =
{ foo : (Maybe String), bar : InnerColumnConstraint }
type InnerColumnConstraint =
InnerColumnConstraint String
"""
, """module ParserTest exposing (suite)
import SQLite.Statement.CreateTable as CreateTable
import Fuzz exposing (Fuzzer)
columnConstraintFuzzer : Fuzzer CreateTable.ColumnConstraint
columnConstraintFuzzer =
Debug.todo ""
"""
]
"""module ParserTest exposing (suite)
import SQLite.Statement.CreateTable as CreateTable
import Fuzz exposing (Fuzzer)
columnConstraintFuzzer : Fuzzer CreateTable.ColumnConstraint
columnConstraintFuzzer =
Fuzz.map2 CreateTable.ColumnConstraint (Fuzz.maybe Fuzz.string) innerColumnConstraintFuzzer
innerColumnConstraintFuzzer : Fuzzer CreateTable.InnerColumnConstraint
innerColumnConstraintFuzzer =
Debug.todo ""
"""
]

0 comments on commit 4eb5a4b

Please sign in to comment.