@@ -117,6 +117,13 @@ preferLocals' region env extract kind possibilities var =
117117 [v] ->
118118 Result.var' extract v
119119
120+ --Local vars shadow top-level vars
121+ [v1, v2] | isTopLevel (extract v1) ->
122+ Result.var' extract v2
123+
124+ [v1, v2] | isTopLevel (extract v2) ->
125+ Result.var' extract v1
126+
120127 locals ->
121128 ambiguous locals
122129 where
@@ -129,10 +136,16 @@ preferLocals' region env extract kind possibilities var =
129136 Var.Module name ->
130137 name == Env._home env
131138
139+ isTopLevel :: Var.Canonical -> Bool
140+ isTopLevel (Var.Canonical home _) =
141+ case home of
142+ Var.TopLevel _ -> True
143+ _ -> False
144+
132145 ambiguous possibleVars =
133146 Result.err (A.A region (Error.variable kind var Error.Ambiguous vars))
134147 where
135− vars = map (Var.toString . extract) possibleVars
148+ vars = map (show {-Var.toString-} . extract) possibleVars
136149
137150
138151-- NOT FOUND HELPERS