Skip to content

Commit 22219ff

Browse files
authored
Merge pull request #120 from miniBill/overqualified-types
Fix local types not needing to be qualified
2 parents de28f1a + bc53396 commit 22219ff

7 files changed

Lines changed: 235 additions & 175 deletions

File tree

review/suppressed/NoUnused.Variables.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
{ "count": 4, "filePath": "src/Internal/Write.elm" },
77
{ "count": 3, "filePath": "src/Internal/Compiler.elm" },
88
{ "count": 3, "filePath": "src/Internal/Debug.elm" },
9-
{ "count": 2, "filePath": "tests/PackageHelpers.elm" },
109
{ "count": 1, "filePath": "src/Elm/Op.elm" },
1110
{ "count": 1, "filePath": "src/Internal/Comments.elm" },
12-
{ "count": 1, "filePath": "src/Internal/Index.elm" }
11+
{ "count": 1, "filePath": "src/Internal/Index.elm" },
12+
{ "count": 1, "filePath": "tests/PackageHelpers.elm" }
1313
]
1414
}

src/Elm.elm

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -518,22 +518,22 @@ withType ((Compiler.Annotation annDetails) as ann) (Compiler.Expression toExp) =
518518
in
519519
{ exp
520520
| annotation =
521-
case Compiler.unifyOn ann exp.annotation of
521+
case Compiler.unifyOn index ann exp.annotation of
522522
Ok unified ->
523523
Ok unified
524524

525525
Err _ ->
526526
case exp.annotation of
527527
Ok expressionAnnotation ->
528528
Ok
529-
{ type_ = annDetails.annotation
529+
{ type_ = annDetails.annotation index
530530
, inferences = expressionAnnotation.inferences
531531
, aliases = expressionAnnotation.aliases
532532
}
533533

534534
Err _ ->
535535
Ok
536-
{ type_ = annDetails.annotation
536+
{ type_ = annDetails.annotation index
537537
, inferences = Dict.empty
538538
, aliases = Compiler.emptyAliases
539539
}
@@ -809,7 +809,7 @@ triple oneExp twoExp threeExp =
809809
(Compiler.noImports oneA.type_)
810810
(Compiler.noImports twoA.type_)
811811
(Compiler.noImports threeA.type_)
812-
|> Compiler.getInnerAnnotation
812+
|> Compiler.getInnerAnnotation index
813813
, inferences =
814814
oneA.inferences
815815
|> Compiler.mergeInferences twoA.inferences
@@ -1384,7 +1384,7 @@ customTypeWith name generics variants =
13841384
variants
13851385
, docs = Nothing
13861386
, toBody =
1387-
\_ ->
1387+
\index ->
13881388
{ warning = Nothing
13891389
, additionalImports = []
13901390
, declaration =
@@ -1400,7 +1400,7 @@ customTypeWith name generics variants =
14001400
(\(Variant _ listAnn) ->
14011401
listAnn
14021402
|> List.concatMap
1403-
Compiler.getGenerics
1403+
(Compiler.getGenerics index)
14041404
)
14051405
variants
14061406
}
@@ -1411,7 +1411,7 @@ customTypeWith name generics variants =
14111411
{ name = Compiler.nodify (Format.formatType varName)
14121412
, arguments =
14131413
List.map
1414-
(Compiler.getInnerAnnotation
1414+
(Compiler.getInnerAnnotation index
14151415
>> Compiler.nodify
14161416
)
14171417
vars
@@ -1518,7 +1518,7 @@ aliasWith name generics innerAnnotation =
15181518
Compiler.getAnnotationImports innerAnnotation
15191519
, docs = Nothing
15201520
, toBody =
1521-
\_ ->
1521+
\index ->
15221522
{ warning = Nothing
15231523
, additionalImports = []
15241524
, declaration =
@@ -1529,9 +1529,9 @@ aliasWith name generics innerAnnotation =
15291529
getGenerics
15301530
{ keepExtra = False
15311531
, requested = generics
1532-
, needed = Compiler.getGenerics innerAnnotation
1532+
, needed = Compiler.getGenerics index innerAnnotation
15331533
}
1534-
, typeAnnotation = Compiler.nodify (Compiler.getInnerAnnotation innerAnnotation)
1534+
, typeAnnotation = Compiler.nodify (Compiler.getInnerAnnotation index innerAnnotation)
15351535
}
15361536
}
15371537
}
@@ -2000,13 +2000,14 @@ function initialArgList toFullExpression =
20002000
Maybe.withDefault
20012001
(Compiler.Annotation
20022002
{ imports = []
2003-
, aliases = Compiler.emptyAliases
2003+
, aliases = \_ -> Compiler.emptyAliases
20042004
, annotation =
2005-
Annotation.GenericType
2006-
(Index.protectTypeName
2007-
nameBase
2008-
found.index
2009-
)
2005+
\_ ->
2006+
Annotation.GenericType
2007+
(Index.protectTypeName
2008+
nameBase
2009+
found.index
2010+
)
20102011
}
20112012
)
20122013
maybeType
@@ -2022,7 +2023,7 @@ function initialArgList toFullExpression =
20222023
{ index = newIndex
20232024
, args = argExpression :: found.args
20242025
, names = name :: found.names
2025-
, types = Compiler.getInnerAnnotation argType :: found.types
2026+
, types = Compiler.getInnerAnnotation newIndex argType :: found.types
20262027
}
20272028
)
20282029
{ args = []
@@ -2079,7 +2080,7 @@ function initialArgList toFullExpression =
20792080
Just ann ->
20802081
aliases
20812082
|> Compiler.mergeAliases
2082-
(Compiler.getAliases ann)
2083+
(Compiler.getAliases index ann)
20832084
)
20842085
return.aliases
20852086
initialArgList
@@ -2176,7 +2177,7 @@ portIncoming nameStr args =
21762177
List.concatMap Compiler.getAnnotationImports args
21772178
, docs = Nothing
21782179
, toBody =
2179-
\_ ->
2180+
\index ->
21802181
{ warning = Nothing
21812182
, additionalImports = []
21822183
, declaration =
@@ -2194,7 +2195,7 @@ portIncoming nameStr args =
21942195
Annotation.FunctionTypeAnnotation
21952196
(groupAnn
21962197
(Compiler.nodify
2197-
(Compiler.getInnerAnnotation
2198+
(Compiler.getInnerAnnotation index
21982199
(Elm.Annotation.function
21992200
args
22002201
(Elm.Annotation.var "msg")
@@ -2248,7 +2249,7 @@ portOutgoing nameStr ann =
22482249
Compiler.getAnnotationImports ann
22492250
, docs = Nothing
22502251
, toBody =
2251-
\_ ->
2252+
\index ->
22522253
{ warning = Nothing
22532254
, additionalImports = []
22542255
, declaration =
@@ -2257,7 +2258,7 @@ portOutgoing nameStr ann =
22572258
, typeAnnotation =
22582259
Compiler.nodify
22592260
(Annotation.FunctionTypeAnnotation
2260-
(Compiler.nodify (Compiler.getInnerAnnotation ann))
2261+
(Compiler.nodify (Compiler.getInnerAnnotation index ann))
22612262
(Compiler.nodify cmd)
22622263
)
22632264
}

0 commit comments

Comments
 (0)