Commit 34d2d463 authored by Krzysztof Gogolewski's avatar Krzysztof Gogolewski Committed by Marge Bot
Browse files

Fix Lint check for duplicate external names

Lint was checking for duplicate external names by calling removeDups,
which needs a comparison function that is passed to Data.List.sortBy.
But the comparison was not a valid ordering - it returned LT
if one of the names was not external.
For example, the previous implementation won't find a duplicate in
[M.x, y, M.x].
Instead, we filter out non-external names before looking for duplicates.
parent be701cc6
Pipeline #62012 canceled with stages
in 30 seconds
......@@ -96,6 +96,7 @@ import Data.Foldable ( for_, toList )
import Data.List.NonEmpty ( NonEmpty(..), groupWith )
import Data.List ( partition )
import Data.Maybe
import Data.Ord ( comparing )
import GHC.Data.Pair
import GHC.Base (oneShot)
import GHC.Data.Unboxed
......@@ -471,17 +472,15 @@ lintCoreBindings' cfg binds
(_, dups) = removeDups compare binders
-- dups_ext checks for names with different uniques
-- ext_dups checks for names with different uniques
-- but the same External name M.n. We don't
-- allow this at top level:
-- M.n{r3} = ...
-- M.n{r29} = ...
-- because they both get the same linker symbol
ext_dups = snd (removeDups ord_ext (map Var.varName binders))
ord_ext n1 n2 | Just m1 <- nameModule_maybe n1
, Just m2 <- nameModule_maybe n2
= compare (m1, nameOccName n1) (m2, nameOccName n2)
| otherwise = LT
ext_dups = snd $ removeDups (comparing ord_ext) $
filter isExternalName $ map Var.varName binders
ord_ext n = (nameModule n, nameOccName n)
{-
************************************************************************
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment