From 1e9a92161ce58d3eb1d35b9b5f9f67e4d1bc03cf Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Tue, 20 Feb 2007 17:47:14 +0000 Subject: [PATCH] Fix obscure bug in reportDeprecations Fixes Trac #1128 Please merge to STABLE A rather obscure bug related to -fno-implicit-prelude. See Note [Used names with interface not loaded] in RnNames. Easily fixed, however. Test is rn051 --- compiler/rename/RnNames.lhs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs index d85089f..8189c2a 100644 --- a/compiler/rename/RnNames.lhs +++ b/compiler/rename/RnNames.lhs @@ -949,18 +949,34 @@ lookupImpDeprec dflags hpt pit gre case gre_par gre of ParentIs p -> mi_dep_fn iface p -- its parent*, is deprec'd NoParent -> Nothing - Nothing - | isWiredInName name -> Nothing - -- We have not necessarily loaded the .hi file for a - -- wired-in name (yet), although we *could*. - -- And we never deprecate them - - | otherwise -> pprPanic "lookupDeprec" (ppr name) - -- By now all the interfaces should have been loaded + + Nothing -> Nothing -- See Note [Used names with interface not loaded] where name = gre_name gre \end{code} +Note [Used names with interface not loaded] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +By now all the interfaces should have been loaded, +because reportDeprecations happens after typechecking. +However, it's still (just) possible to to find a used +Name whose interface hasn't been loaded: + +a) It might be a WiredInName; in that case we may not load + its interface (although we could). + +b) It might be GHC.Real.fromRational, or GHC.Num.fromInteger + These are seen as "used" by the renamer (if -fno-implicit-prelude) + is on), but the typechecker may discard their uses + if in fact the in-scope fromRational is GHC.Read.fromRational, + (see tcPat.tcOverloadedLit), and the typechecker sees that the type + is fixed, say, to GHC.Base.Float (see Inst.lookupSimpleInst). + In that obscure case it won't force the interface in. + +In both cases we simply don't permit deprecations; +this is, after all, wired-in stuff. + + %********************************************************* %* * Unused names -- 1.7.10.4