Move isJoinId, isJoinId_maybe to Id
[ghc.git] / compiler / basicTypes / Var.hs
1 {-
2 (c) The University of Glasgow 2006
3 (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4
5 \section{@Vars@: Variables}
6 -}
7
8 {-# LANGUAGE CPP, MultiWayIf, FlexibleInstances, DeriveDataTypeable #-}
9
10 -- |
11 -- #name_types#
12 -- GHC uses several kinds of name internally:
13 --
14 -- * 'OccName.OccName': see "OccName#name_types"
15 --
16 -- * 'RdrName.RdrName': see "RdrName#name_types"
17 --
18 -- * 'Name.Name': see "Name#name_types"
19 --
20 -- * 'Id.Id': see "Id#name_types"
21 --
22 -- * 'Var.Var' is a synonym for the 'Id.Id' type but it may additionally
23 -- potentially contain type variables, which have a 'TyCoRep.Kind'
24 -- rather than a 'TyCoRep.Type' and only contain some extra
25 -- details during typechecking.
26 --
27 -- These 'Var.Var' names may either be global or local, see "Var#globalvslocal"
28 --
29 -- #globalvslocal#
30 -- Global 'Id's and 'Var's are those that are imported or correspond
31 -- to a data constructor, primitive operation, or record selectors.
32 -- Local 'Id's and 'Var's are those bound within an expression
33 -- (e.g. by a lambda) or at the top level of the module being compiled.
34
35 module Var (
36 -- * The main data type and synonyms
37 Var, CoVar, Id, NcId, DictId, DFunId, EvVar, EqVar, EvId, IpId, JoinId,
38 TyVar, TypeVar, KindVar, TKVar, TyCoVar,
39
40 -- * In and Out variants
41 InVar, InCoVar, InId, InTyVar,
42 OutVar, OutCoVar, OutId, OutTyVar,
43
44 -- ** Taking 'Var's apart
45 varName, varUnique, varType,
46
47 -- ** Modifying 'Var's
48 setVarName, setVarUnique, setVarType, updateVarType,
49 updateVarTypeM,
50
51 -- ** Constructing, taking apart, modifying 'Id's
52 mkGlobalVar, mkLocalVar, mkExportedLocalVar, mkCoVar,
53 idInfo, idDetails,
54 lazySetIdInfo, setIdDetails, globaliseId,
55 setIdExported, setIdNotExported,
56
57 -- ** Predicates
58 isId, isTyVar, isTcTyVar,
59 isLocalVar, isLocalId, isCoVar, isNonCoVarId, isTyCoVar,
60 isGlobalId, isExportedId,
61 mustHaveLocalBinding,
62
63 -- * TyVar's
64 TyVarBndr(..), ArgFlag(..), TyVarBinder,
65 binderVar, binderVars, binderArgFlag, binderKind,
66 isVisibleArgFlag, isInvisibleArgFlag, sameVis,
67
68 -- ** Constructing TyVar's
69 mkTyVar, mkTcTyVar,
70
71 -- ** Taking 'TyVar's apart
72 tyVarName, tyVarKind, tcTyVarDetails, setTcTyVarDetails,
73
74 -- ** Modifying 'TyVar's
75 setTyVarName, setTyVarUnique, setTyVarKind, updateTyVarKind,
76 updateTyVarKindM,
77
78 nonDetCmpVar
79
80 ) where
81
82 #include "HsVersions.h"
83
84 import {-# SOURCE #-} TyCoRep( Type, Kind, pprKind )
85 import {-# SOURCE #-} TcType( TcTyVarDetails, pprTcTyVarDetails, vanillaSkolemTv )
86 import {-# SOURCE #-} IdInfo( IdDetails, IdInfo, coVarDetails, isCoVarDetails,
87 vanillaIdInfo, pprIdDetails )
88
89 import Name hiding (varName)
90 import Unique ( Uniquable, Unique, getKey, getUnique
91 , mkUniqueGrimily, nonDetCmpUnique )
92 import Util
93 import Binary
94 import DynFlags
95 import Outputable
96
97 import Data.Data
98
99 {-
100 ************************************************************************
101 * *
102 Synonyms
103 * *
104 ************************************************************************
105 -- These synonyms are here and not in Id because otherwise we need a very
106 -- large number of SOURCE imports of Id.hs :-(
107 -}
108
109 -- | Identifier
110 type Id = Var -- A term-level identifier
111 -- predicate: isId
112
113 -- | Coercion Variable
114 type CoVar = Id -- See Note [Evidence: EvIds and CoVars]
115 -- predicate: isCoVar
116
117 -- |
118 type NcId = Id -- A term-level (value) variable that is
119 -- /not/ an (unlifted) coercion
120 -- predicate: isNonCoVarId
121
122 -- | Type or kind Variable
123 type TyVar = Var -- Type *or* kind variable (historical)
124
125 -- | Type or Kind Variable
126 type TKVar = Var -- Type *or* kind variable (historical)
127
128 -- | Type Variable
129 type TypeVar = Var -- Definitely a type variable
130
131 -- | Kind Variable
132 type KindVar = Var -- Definitely a kind variable
133 -- See Note [Kind and type variables]
134
135 -- See Note [Evidence: EvIds and CoVars]
136 -- | Evidence Identifier
137 type EvId = Id -- Term-level evidence: DictId, IpId, or EqVar
138
139 -- | Evidence Variable
140 type EvVar = EvId -- ...historical name for EvId
141
142 -- | Dictionary Function Identifier
143 type DFunId = Id -- A dictionary function
144
145 -- | Dictionary Identifier
146 type DictId = EvId -- A dictionary variable
147
148 -- | Implicit parameter Identifier
149 type IpId = EvId -- A term-level implicit parameter
150
151 -- | Equality Variable
152 type EqVar = EvId -- Boxed equality evidence
153 type JoinId = Id -- A join variable
154
155 -- | Type or Coercion Variable
156 type TyCoVar = Id -- Type, *or* coercion variable
157 -- predicate: isTyCoVar
158
159
160 {- Many passes apply a substitution, and it's very handy to have type
161 synonyms to remind us whether or not the subsitution has been applied -}
162
163 type InVar = Var
164 type InTyVar = TyVar
165 type InCoVar = CoVar
166 type InId = Id
167 type OutVar = Var
168 type OutTyVar = TyVar
169 type OutCoVar = CoVar
170 type OutId = Id
171
172
173
174 {- Note [Evidence: EvIds and CoVars]
175 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176 * An EvId (evidence Id) is a term-level evidence variable
177 (dictionary, implicit parameter, or equality). Could be boxed or unboxed.
178
179 * DictId, IpId, and EqVar are synonyms when we know what kind of
180 evidence we are talking about. For example, an EqVar has type (t1 ~ t2).
181
182 * A CoVar is always an un-lifted coercion, of type (t1 ~# t2) or (t1 ~R# t2)
183
184 Note [Kind and type variables]
185 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
186 Before kind polymorphism, TyVar were used to mean type variables. Now
187 they are use to mean kind *or* type variables. KindVar is used when we
188 know for sure that it is a kind variable. In future, we might want to
189 go over the whole compiler code to use:
190 - TKVar to mean kind or type variables
191 - TypeVar to mean type variables only
192 - KindVar to mean kind variables
193
194
195 ************************************************************************
196 * *
197 \subsection{The main data type declarations}
198 * *
199 ************************************************************************
200
201
202 Every @Var@ has a @Unique@, to uniquify it and for fast comparison, a
203 @Type@, and an @IdInfo@ (non-essential info about it, e.g.,
204 strictness). The essential info about different kinds of @Vars@ is
205 in its @VarDetails@.
206 -}
207
208 -- | Variable
209 --
210 -- Essentially a typed 'Name', that may also contain some additional information
211 -- about the 'Var' and it's use sites.
212 data Var
213 = TyVar { -- Type and kind variables
214 -- see Note [Kind and type variables]
215 varName :: !Name,
216 realUnique :: {-# UNPACK #-} !Int,
217 -- ^ Key for fast comparison
218 -- Identical to the Unique in the name,
219 -- cached here for speed
220 varType :: Kind -- ^ The type or kind of the 'Var' in question
221 }
222
223 | TcTyVar { -- Used only during type inference
224 -- Used for kind variables during
225 -- inference, as well
226 varName :: !Name,
227 realUnique :: {-# UNPACK #-} !Int,
228 varType :: Kind,
229 tc_tv_details :: TcTyVarDetails
230 }
231
232 | Id {
233 varName :: !Name,
234 realUnique :: {-# UNPACK #-} !Int,
235 varType :: Type,
236 idScope :: IdScope,
237 id_details :: IdDetails, -- Stable, doesn't change
238 id_info :: IdInfo } -- Unstable, updated by simplifier
239
240 -- | Identifier Scope
241 data IdScope -- See Note [GlobalId/LocalId]
242 = GlobalId
243 | LocalId ExportFlag
244
245 data ExportFlag -- See Note [ExportFlag on binders]
246 = NotExported -- ^ Not exported: may be discarded as dead code.
247 | Exported -- ^ Exported: kept alive
248
249 {- Note [ExportFlag on binders]
250 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
251 An ExportFlag of "Exported" on a top-level binder says "keep this
252 binding alive; do not drop it as dead code". This transitively
253 keeps alive all the other top-level bindings that this binding refers
254 to. This property is persisted all the way down the pipeline, so that
255 the binding will be compiled all the way to object code, and its
256 symbols will appear in the linker symbol table.
257
258 However, note that this use of "exported" is quite different to the
259 export list on a Haskell module. Setting the ExportFlag on an Id does
260 /not/ mean that if you import the module (in Haskell source code) you
261 will see this Id. Of course, things that appear in the export list
262 of the source Haskell module do indeed have their ExportFlag set.
263 But many other things, such as dictionary functions, are kept alive
264 by having their ExportFlag set, even though they are not exported
265 in the source-code sense.
266
267 We should probably use a different term for ExportFlag, like
268 KeepAlive.
269
270 Note [GlobalId/LocalId]
271 ~~~~~~~~~~~~~~~~~~~~~~~
272 A GlobalId is
273 * always a constant (top-level)
274 * imported, or data constructor, or primop, or record selector
275 * has a Unique that is globally unique across the whole
276 GHC invocation (a single invocation may compile multiple modules)
277 * never treated as a candidate by the free-variable finder;
278 it's a constant!
279
280 A LocalId is
281 * bound within an expression (lambda, case, local let(rec))
282 * or defined at top level in the module being compiled
283 * always treated as a candidate by the free-variable finder
284
285 After CoreTidy, top-level LocalIds are turned into GlobalIds
286 -}
287
288 instance Outputable Var where
289 ppr var = sdocWithDynFlags $ \dflags ->
290 getPprStyle $ \ppr_style ->
291 if | debugStyle ppr_style && (not (gopt Opt_SuppressVarKinds dflags))
292 -> parens (ppr (varName var) <+> ppr_debug var ppr_style <+>
293 dcolon <+> pprKind (tyVarKind var))
294 | otherwise
295 -> ppr (varName var) <> ppr_debug var ppr_style
296
297 ppr_debug :: Var -> PprStyle -> SDoc
298 ppr_debug (TyVar {}) sty
299 | debugStyle sty = brackets (text "tv")
300 ppr_debug (TcTyVar {tc_tv_details = d}) sty
301 | dumpStyle sty || debugStyle sty = brackets (pprTcTyVarDetails d)
302 ppr_debug (Id { idScope = s, id_details = d }) sty
303 | debugStyle sty = brackets (ppr_id_scope s <> pprIdDetails d)
304 ppr_debug _ _ = empty
305
306 ppr_id_scope :: IdScope -> SDoc
307 ppr_id_scope GlobalId = text "gid"
308 ppr_id_scope (LocalId Exported) = text "lidx"
309 ppr_id_scope (LocalId NotExported) = text "lid"
310
311 instance NamedThing Var where
312 getName = varName
313
314 instance Uniquable Var where
315 getUnique = varUnique
316
317 instance Eq Var where
318 a == b = realUnique a == realUnique b
319
320 instance Ord Var where
321 a <= b = realUnique a <= realUnique b
322 a < b = realUnique a < realUnique b
323 a >= b = realUnique a >= realUnique b
324 a > b = realUnique a > realUnique b
325 a `compare` b = a `nonDetCmpVar` b
326
327 -- | Compare Vars by their Uniques.
328 -- This is what Ord Var does, provided here to make it explicit at the
329 -- call-site that it can introduce non-determinism.
330 -- See Note [Unique Determinism]
331 nonDetCmpVar :: Var -> Var -> Ordering
332 nonDetCmpVar a b = varUnique a `nonDetCmpUnique` varUnique b
333
334 instance Data Var where
335 -- don't traverse?
336 toConstr _ = abstractConstr "Var"
337 gunfold _ _ = error "gunfold"
338 dataTypeOf _ = mkNoRepType "Var"
339
340 instance HasOccName Var where
341 occName = nameOccName . varName
342
343 varUnique :: Var -> Unique
344 varUnique var = mkUniqueGrimily (realUnique var)
345
346 setVarUnique :: Var -> Unique -> Var
347 setVarUnique var uniq
348 = var { realUnique = getKey uniq,
349 varName = setNameUnique (varName var) uniq }
350
351 setVarName :: Var -> Name -> Var
352 setVarName var new_name
353 = var { realUnique = getKey (getUnique new_name),
354 varName = new_name }
355
356 setVarType :: Id -> Type -> Id
357 setVarType id ty = id { varType = ty }
358
359 updateVarType :: (Type -> Type) -> Id -> Id
360 updateVarType f id = id { varType = f (varType id) }
361
362 updateVarTypeM :: Monad m => (Type -> m Type) -> Id -> m Id
363 updateVarTypeM f id = do { ty' <- f (varType id)
364 ; return (id { varType = ty' }) }
365
366 {- *********************************************************************
367 * *
368 * ArgFlag
369 * *
370 ********************************************************************* -}
371
372 -- | Argument Flag
373 --
374 -- Is something required to appear in source Haskell ('Required'),
375 -- permitted by request ('Specified') (visible type application), or
376 -- prohibited entirely from appearing in source Haskell ('Inferred')?
377 -- See Note [TyBinders and ArgFlags] in TyCoRep
378 data ArgFlag = Required | Specified | Inferred
379 deriving (Eq, Data)
380
381 -- | Does this 'ArgFlag' classify an argument that is written in Haskell?
382 isVisibleArgFlag :: ArgFlag -> Bool
383 isVisibleArgFlag Required = True
384 isVisibleArgFlag _ = False
385
386 -- | Does this 'ArgFlag' classify an argument that is not written in Haskell?
387 isInvisibleArgFlag :: ArgFlag -> Bool
388 isInvisibleArgFlag = not . isVisibleArgFlag
389
390 -- | Do these denote the same level of visibility? 'Required'
391 -- arguments are visible, others are not. So this function
392 -- equates 'Specified' and 'Inferred'. Used for printing.
393 sameVis :: ArgFlag -> ArgFlag -> Bool
394 sameVis Required Required = True
395 sameVis Required _ = False
396 sameVis _ Required = False
397 sameVis _ _ = True
398
399 {- *********************************************************************
400 * *
401 * TyVarBndr, TyVarBinder
402 * *
403 ********************************************************************* -}
404
405 -- Type Variable Binder
406 --
407 -- TyVarBndr is polymorphic in both tyvar and visiblity fields:
408 -- * tyvar can be TyVar or IfaceTv
409 -- * argf can be ArgFlag or TyConBndrVis
410 data TyVarBndr tyvar argf = TvBndr tyvar argf
411 deriving( Data )
412
413 -- | Type Variable Binder
414 --
415 -- A 'TyVarBinder' is the binder of a ForAllTy
416 -- It's convenient to define this synonym here rather its natural
417 -- home in TyCoRep, because it's used in DataCon.hs-boot
418 type TyVarBinder = TyVarBndr TyVar ArgFlag
419
420 binderVar :: TyVarBndr tv argf -> tv
421 binderVar (TvBndr v _) = v
422
423 binderVars :: [TyVarBndr tv argf] -> [tv]
424 binderVars tvbs = map binderVar tvbs
425
426 binderArgFlag :: TyVarBndr tv argf -> argf
427 binderArgFlag (TvBndr _ argf) = argf
428
429 binderKind :: TyVarBndr TyVar argf -> Kind
430 binderKind (TvBndr tv _) = tyVarKind tv
431
432 {-
433 ************************************************************************
434 * *
435 * Type and kind variables *
436 * *
437 ************************************************************************
438 -}
439
440 tyVarName :: TyVar -> Name
441 tyVarName = varName
442
443 tyVarKind :: TyVar -> Kind
444 tyVarKind = varType
445
446 setTyVarUnique :: TyVar -> Unique -> TyVar
447 setTyVarUnique = setVarUnique
448
449 setTyVarName :: TyVar -> Name -> TyVar
450 setTyVarName = setVarName
451
452 setTyVarKind :: TyVar -> Kind -> TyVar
453 setTyVarKind tv k = tv {varType = k}
454
455 updateTyVarKind :: (Kind -> Kind) -> TyVar -> TyVar
456 updateTyVarKind update tv = tv {varType = update (tyVarKind tv)}
457
458 updateTyVarKindM :: (Monad m) => (Kind -> m Kind) -> TyVar -> m TyVar
459 updateTyVarKindM update tv
460 = do { k' <- update (tyVarKind tv)
461 ; return $ tv {varType = k'} }
462
463 mkTyVar :: Name -> Kind -> TyVar
464 mkTyVar name kind = TyVar { varName = name
465 , realUnique = getKey (nameUnique name)
466 , varType = kind
467 }
468
469 mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar
470 mkTcTyVar name kind details
471 = -- NB: 'kind' may be a coercion kind; cf, 'TcMType.newMetaCoVar'
472 TcTyVar { varName = name,
473 realUnique = getKey (nameUnique name),
474 varType = kind,
475 tc_tv_details = details
476 }
477
478 tcTyVarDetails :: TyVar -> TcTyVarDetails
479 -- See Note [TcTyVars in the typechecker] in TcType
480 tcTyVarDetails (TcTyVar { tc_tv_details = details }) = details
481 tcTyVarDetails (TyVar {}) = vanillaSkolemTv
482 tcTyVarDetails var = pprPanic "tcTyVarDetails" (ppr var <+> dcolon <+> pprKind (tyVarKind var))
483
484 setTcTyVarDetails :: TyVar -> TcTyVarDetails -> TyVar
485 setTcTyVarDetails tv details = tv { tc_tv_details = details }
486
487 -------------------------------------
488 instance Outputable tv => Outputable (TyVarBndr tv ArgFlag) where
489 ppr (TvBndr v Required) = ppr v
490 ppr (TvBndr v Specified) = char '@' <> ppr v
491 ppr (TvBndr v Inferred) = braces (ppr v)
492
493 instance Outputable ArgFlag where
494 ppr Required = text "[req]"
495 ppr Specified = text "[spec]"
496 ppr Inferred = text "[infrd]"
497
498 instance (Binary tv, Binary vis) => Binary (TyVarBndr tv vis) where
499 put_ bh (TvBndr tv vis) = do { put_ bh tv; put_ bh vis }
500
501 get bh = do { tv <- get bh; vis <- get bh; return (TvBndr tv vis) }
502
503
504 instance Binary ArgFlag where
505 put_ bh Required = putByte bh 0
506 put_ bh Specified = putByte bh 1
507 put_ bh Inferred = putByte bh 2
508
509 get bh = do
510 h <- getByte bh
511 case h of
512 0 -> return Required
513 1 -> return Specified
514 _ -> return Inferred
515
516 {-
517 %************************************************************************
518 %* *
519 \subsection{Ids}
520 * *
521 ************************************************************************
522 -}
523
524 idInfo :: Id -> IdInfo
525 idInfo (Id { id_info = info }) = info
526 idInfo other = pprPanic "idInfo" (ppr other)
527
528 idDetails :: Id -> IdDetails
529 idDetails (Id { id_details = details }) = details
530 idDetails other = pprPanic "idDetails" (ppr other)
531
532 -- The next three have a 'Var' suffix even though they always build
533 -- Ids, because Id.hs uses 'mkGlobalId' etc with different types
534 mkGlobalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
535 mkGlobalVar details name ty info
536 = mk_id name ty GlobalId details info
537
538 mkLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
539 mkLocalVar details name ty info
540 = mk_id name ty (LocalId NotExported) details info
541
542 mkCoVar :: Name -> Type -> CoVar
543 -- Coercion variables have no IdInfo
544 mkCoVar name ty = mk_id name ty (LocalId NotExported) coVarDetails vanillaIdInfo
545
546 -- | Exported 'Var's will not be removed as dead code
547 mkExportedLocalVar :: IdDetails -> Name -> Type -> IdInfo -> Id
548 mkExportedLocalVar details name ty info
549 = mk_id name ty (LocalId Exported) details info
550
551 mk_id :: Name -> Type -> IdScope -> IdDetails -> IdInfo -> Id
552 mk_id name ty scope details info
553 = Id { varName = name,
554 realUnique = getKey (nameUnique name),
555 varType = ty,
556 idScope = scope,
557 id_details = details,
558 id_info = info }
559
560 -------------------
561 lazySetIdInfo :: Id -> IdInfo -> Var
562 lazySetIdInfo id info = id { id_info = info }
563
564 setIdDetails :: Id -> IdDetails -> Id
565 setIdDetails id details = id { id_details = details }
566
567 globaliseId :: Id -> Id
568 -- ^ If it's a local, make it global
569 globaliseId id = id { idScope = GlobalId }
570
571 setIdExported :: Id -> Id
572 -- ^ Exports the given local 'Id'. Can also be called on global 'Id's, such as data constructors
573 -- and class operations, which are born as global 'Id's and automatically exported
574 setIdExported id@(Id { idScope = LocalId {} }) = id { idScope = LocalId Exported }
575 setIdExported id@(Id { idScope = GlobalId }) = id
576 setIdExported tv = pprPanic "setIdExported" (ppr tv)
577
578 setIdNotExported :: Id -> Id
579 -- ^ We can only do this to LocalIds
580 setIdNotExported id = ASSERT( isLocalId id )
581 id { idScope = LocalId NotExported }
582
583 {-
584 ************************************************************************
585 * *
586 \subsection{Predicates over variables}
587 * *
588 ************************************************************************
589 -}
590
591 isTyVar :: Var -> Bool -- True of both TyVar and TcTyVar
592 isTyVar (TyVar {}) = True
593 isTyVar (TcTyVar {}) = True
594 isTyVar _ = False
595
596 isTcTyVar :: Var -> Bool -- True of TcTyVar only
597 isTcTyVar (TcTyVar {}) = True
598 isTcTyVar _ = False
599
600 isTyCoVar :: Var -> Bool
601 isTyCoVar v = isTyVar v || isCoVar v
602
603 isId :: Var -> Bool
604 isId (Id {}) = True
605 isId _ = False
606
607 isCoVar :: Var -> Bool
608 -- A coercion variable
609 isCoVar (Id { id_details = details }) = isCoVarDetails details
610 isCoVar _ = False
611
612 isNonCoVarId :: Var -> Bool
613 -- A term variable (Id) that is /not/ a coercion variable
614 isNonCoVarId (Id { id_details = details }) = not (isCoVarDetails details)
615 isNonCoVarId _ = False
616
617 isLocalId :: Var -> Bool
618 isLocalId (Id { idScope = LocalId _ }) = True
619 isLocalId _ = False
620
621 -- | 'isLocalVar' returns @True@ for type variables as well as local 'Id's
622 -- These are the variables that we need to pay attention to when finding free
623 -- variables, or doing dependency analysis.
624 isLocalVar :: Var -> Bool
625 isLocalVar v = not (isGlobalId v)
626
627 isGlobalId :: Var -> Bool
628 isGlobalId (Id { idScope = GlobalId }) = True
629 isGlobalId _ = False
630
631 -- | 'mustHaveLocalBinding' returns @True@ of 'Id's and 'TyVar's
632 -- that must have a binding in this module. The converse
633 -- is not quite right: there are some global 'Id's that must have
634 -- bindings, such as record selectors. But that doesn't matter,
635 -- because it's only used for assertions
636 mustHaveLocalBinding :: Var -> Bool
637 mustHaveLocalBinding var = isLocalVar var
638
639 -- | 'isExportedIdVar' means \"don't throw this away\"
640 isExportedId :: Var -> Bool
641 isExportedId (Id { idScope = GlobalId }) = True
642 isExportedId (Id { idScope = LocalId Exported}) = True
643 isExportedId _ = False