@@ -117,6 +117,13 @@ preferLocals' region env extract kind possibilities var =
118 Result.var' extract v
118 Result.var' extract v
120+ --Local vars shadow top-level vars
121+ [v1, v2] | isTopLevel (extract v1) ->
122+ Result.var' extract v2
124+ [v1, v2] | isTopLevel (extract v2) ->
125+ Result.var' extract v1
120 locals ->
127 locals ->
121 ambiguous locals
128 ambiguous locals
@@ -129,10 +136,16 @@ preferLocals' region env extract kind possibilities var =
129 Var.Module name ->
136 Var.Module name ->
130 name == Env._home env
137 name == Env._home env
139+ isTopLevel :: Var.Canonical -> Bool
140+ isTopLevel (Var.Canonical home _) =
142+ Var.TopLevel _ -> True
132 ambiguous possibleVars =
145 ambiguous possibleVars =
133 Result.err (A.A region (Error.variable kind var Error.Ambiguous vars))
146 Result.err (A.A region (Error.variable kind var Error.Ambiguous vars))
135− vars = map (Var.toString . extract) possibleVars
148+ vars = map (show {-Var.toString-} . extract) possibleVars
138-- NOT FOUND HELPERS
151-- NOT FOUND HELPERS