2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[RnPat]{Renaming of patterns}
6 Basically dependency analysis.
8 Handles @Match@, @GRHSs@, @HsExpr@, and @Qualifier@ datatypes. In
9 general, all of these functions return a renamed thing, and a set of
14 -- The above warning supression flag is a temporary kludge.
15 -- While working on this module you are encouraged to remove it and fix
16 -- any warnings in the module. See
17 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
20 module RnPat (-- main entry points
21 rnPatsAndThen_LocalRightwards, rnBindPat,
23 NameMaker, applyNameMaker, -- a utility for making names:
24 localRecNameMaker, topRecNameMaker, -- sometimes we want to make local names,
25 -- sometimes we want to make top (qualified) names.
27 rnHsRecFields_Con, rnHsRecFields_Update, --rename record fields in a constructor
36 -- Pattern Error messages that are also used elsewhere
37 checkTupSize, patSigErr
40 -- ENH: thin imports to only what is necessary for patterns
42 import {-# SOURCE #-} RnExpr( rnLExpr, rnStmts)
44 import {-# SOURCE #-} TcSplice( runQuasiQuotePat )
47 #include "HsVersions.h"
52 import HscTypes ( availNames )
53 import RnNames ( getLocalDeclBinders, extendRdrEnvRn )
54 import RnTypes ( rnHsTypeFVs,
55 mkOpFormRn, mkOpAppRn, mkNegAppRn, checkSectionPrec, mkConOpPatRn
57 import DynFlags ( DynFlag(..) )
58 import BasicTypes ( FixityDirection(..) )
59 import SrcLoc ( SrcSpan )
60 import PrelNames ( thFAKE, hasKey, assertIdKey, assertErrorName,
61 loopAName, choiceAName, appAName, arrAName, composeAName, firstAName,
62 negateName, thenMName, bindMName, failMName,
63 eqClassName, integralClassName, geName, eqName,
64 negateName, minusName, lengthPName, indexPName,
65 plusIntegerName, fromIntegerName, timesIntegerName,
66 ratioDataConName, fromRationalName, fromStringName, mkUnboundName )
67 import Constants ( mAX_TUPLE_SIZE )
68 import Name ( Name, nameOccName, nameModule_maybe, getOccName, nameSrcSpan )
69 import OccName ( occEnvElts )
72 import RdrName ( RdrName, GlobalRdrElt(..), Provenance(..),
73 extendLocalRdrEnv, lookupLocalRdrEnv, hideSomeUnquals,
74 mkRdrUnqual, nameRdrName, gre_name, globalRdrEnvElts, isLocalGRE )
75 import LoadIface ( loadInterfaceForName )
76 import UniqFM ( isNullUFM )
77 import UniqSet ( emptyUniqSet )
79 import Util ( isSingleton )
80 import ListSetOps ( removeDups, minusList )
81 import Maybes ( expectJust )
83 import SrcLoc ( Located(..), unLoc, getLoc, cmpLocated, noLoc )
85 import Literal ( inIntRange, inCharRange )
86 import List ( unzip4 )
89 import ErrUtils (Message)
93 *********************************************************
97 *********************************************************
100 -- externally abstract type of name makers,
101 -- which is how you go from a RdrName to a Name
102 data NameMaker = NM (forall a. Located RdrName -> (Name -> RnM (a, FreeVars))
103 -> RnM (a, FreeVars))
105 matchNameMaker :: NameMaker
107 = NM (\ rdr_name thing_inside ->
108 do { names@[name] <- newLocalsRn [rdr_name]
109 ; bindLocalNamesFV names $
110 warnUnusedMatches names $
113 topRecNameMaker, localRecNameMaker
114 :: UniqFM (Located Fixity) -- mini fixity env for the names we're about to bind
115 -- these fixities need to be brought into scope with the names
118 -- topNameMaker and localBindMaker do not check for unused binding
119 localRecNameMaker fix_env
120 = NM (\ rdr_name thing_inside ->
121 do { [name] <- newLocalsRn [rdr_name]
122 ; bindLocalNamesFV_WithFixities [name] fix_env $
125 topRecNameMaker fix_env
126 = NM (\rdr_name thing_inside ->
127 do { mod <- getModule
128 ; name <- newTopSrcBinder mod rdr_name
129 ; bindLocalNamesFV_WithFixities [name] fix_env $
131 -- Note: the bindLocalNamesFV_WithFixities is somewhat suspicious
132 -- because it binds a top-level name as a local name.
133 -- however, this binding seems to work, and it only exists for
134 -- the duration of the patterns and the continuation;
135 -- then the top-level name is added to the global env
136 -- before going on to the RHSes (see RnSource.lhs).
138 applyNameMaker :: NameMaker -> Located RdrName
139 -> (Name -> RnM (a,FreeVars)) -> RnM (a, FreeVars)
140 applyNameMaker (NM f) = f
143 -- There are various entry points to renaming patterns, depending on
144 -- (1) whether the names created should be top-level names or local names
145 -- (2) whether the scope of the names is entirely given in a continuation
146 -- (e.g., in a case or lambda, but not in a let or at the top-level,
147 -- because of the way mutually recursive bindings are handled)
148 -- (3) whether the a type signature in the pattern can bind
149 -- lexically-scoped type variables (for unpacking existential
150 -- type vars in data constructors)
151 -- (4) whether we do duplicate and unused variable checking
152 -- (5) whether there are fixity declarations associated with the names
153 -- bound by the patterns that need to be brought into scope with them.
155 -- Rather than burdening the clients of this module with all of these choices,
156 -- we export the three points in this design space that we actually need:
159 -- binds local names; the scope of the bindings is entirely in the thing_inside
160 -- allows type sigs to bind type vars
162 -- unused and duplicate checking
164 rnPatsAndThen_LocalRightwards :: HsMatchContext Name -- for error messages
166 -- the continuation gets:
167 -- the list of renamed patterns
168 -- the (overall) free vars of all of them
169 -> ([LPat Name] -> RnM (a, FreeVars))
172 rnPatsAndThen_LocalRightwards ctxt pats thing_inside
173 = do { envs_before <- getRdrEnvs
175 -- (0) bring into scope all of the type variables bound by the patterns
176 -- (1) rename the patterns, bringing into scope all of the term variables
177 -- (2) then do the thing inside.
178 ; bindPatSigTyVarsFV (collectSigTysFromPats pats) $
179 rnLPatsAndThen matchNameMaker pats $ \ pats' ->
180 do { -- Check for duplicated and shadowed names
181 -- Because we don't bind the vars all at once, we can't
182 -- check incrementally for duplicates;
183 -- Nor can we check incrementally for shadowing, else we'll
184 -- complain *twice* about duplicates e.g. f (x,x) = ...
185 ; let names = collectPatsBinders pats'
186 ; checkDupNames doc_pat names
187 ; checkShadowedNames doc_pat envs_before
188 [(nameSrcSpan name, nameOccName name) | name <- names]
189 ; thing_inside pats' } }
191 doc_pat = ptext SLIT("In") <+> pprMatchContext ctxt
195 -- binds local names; in a recursive scope that involves other bound vars
196 -- e.g let { (x, Just y) = e1; ... } in ...
197 -- does NOT allows type sig to bind type vars
199 -- no unused and duplicate checking
200 -- fixities might be coming in
201 rnBindPat :: NameMaker
204 -- free variables of the pattern,
205 -- but not including variables bound by this pattern
208 rnBindPat name_maker pat
209 = rnLPatsAndThen name_maker [pat] $ \ [pat'] ->
210 return (pat', emptyFVs)
213 -- general version: parametrized by how you make new names
214 -- invariant: what-to-do continuation only gets called with a list whose length is the same as
215 -- the part of the pattern we're currently renaming
216 rnLPatsAndThen :: NameMaker -- how to make a new variable
217 -> [LPat RdrName] -- part of pattern we're currently renaming
218 -> ([LPat Name] -> RnM (a, FreeVars)) -- what to do afterwards
219 -> RnM (a, FreeVars) -- renaming of the whole thing
221 rnLPatsAndThen var = mapFvRnCPS (rnLPatAndThen var)
225 rnLPatAndThen :: NameMaker
226 -> LPat RdrName -- part of pattern we're currently renaming
227 -> (LPat Name -> RnM (a, FreeVars)) -- what to do afterwards
228 -> RnM (a, FreeVars) -- renaming of the whole thing
229 rnLPatAndThen var@(NM varf) (L loc p) cont =
232 lcont = \ unlocated -> cont (reloc unlocated)
235 WildPat _ -> lcont (WildPat placeHolderType)
237 ParPat pat -> rnLPatAndThen var pat $ \ pat' -> lcont (ParPat pat')
238 LazyPat pat -> rnLPatAndThen var pat $ \ pat' -> lcont (LazyPat pat')
239 BangPat pat -> rnLPatAndThen var pat $ \ pat' -> lcont (BangPat pat')
242 varf (reloc name) $ \ newBoundName ->
243 lcont (VarPat newBoundName)
244 -- we need to bind pattern variables for view pattern expressions
245 -- (e.g. in the pattern (x, x -> y) x needs to be bound in the rhs of the tuple)
247 SigPatIn pat ty -> do
248 patsigs <- doptM Opt_PatternSignatures
250 then rnLPatAndThen var pat
251 (\ pat' -> do { (ty', fvs1) <- rnHsTypeFVs tvdoc ty
252 ; (res, fvs2) <- lcont (SigPatIn pat' ty')
253 ; return (res, fvs1 `plusFV` fvs2) })
254 else do addErr (patSigErr ty)
255 rnLPatAndThen var pat cont
257 tvdoc = text "In a pattern type-signature"
259 LitPat lit@(HsString s) ->
260 do ovlStr <- doptM Opt_OverloadedStrings
262 then rnLPatAndThen var (reloc $ mkNPat (mkHsIsString s placeHolderType) Nothing) cont
263 else do { rnLit lit; lcont (LitPat lit) } -- Same as below
265 LitPat lit -> do { rnLit lit; lcont (LitPat lit) }
267 NPat lit mb_neg eq ->
268 do { (lit', fvs1) <- rnOverLit lit
269 ; (mb_neg', fvs2) <- case mb_neg of
270 Nothing -> return (Nothing, emptyFVs)
271 Just _ -> do { (neg, fvs) <- lookupSyntaxName negateName
272 ; return (Just neg, fvs) }
273 ; (eq', fvs3) <- lookupSyntaxName eqName
274 ; (res, fvs4) <- lcont (NPat lit' mb_neg' eq')
275 ; return (res, fvs1 `plusFV` fvs2 `plusFV` fvs3 `plusFV` fvs4) }
276 -- Needed to find equality on pattern
278 NPlusKPat name lit _ _ ->
279 varf name $ \ new_name ->
280 do { (lit', fvs1) <- rnOverLit lit
281 ; (minus, fvs2) <- lookupSyntaxName minusName
282 ; (ge, fvs3) <- lookupSyntaxName geName
283 ; (res, fvs4) <- lcont (NPlusKPat (L (nameSrcSpan new_name) new_name) lit' ge minus)
284 ; return (res, fvs1 `plusFV` fvs2 `plusFV` fvs3 `plusFV` fvs4) }
285 -- The Report says that n+k patterns must be in Integral
288 varf name $ \ new_name ->
289 rnLPatAndThen var pat $ \ pat' ->
290 lcont (AsPat (L (nameSrcSpan new_name) new_name) pat')
292 ViewPat expr pat ty ->
293 do { vp_flag <- doptM Opt_ViewPatterns
294 ; checkErr vp_flag (badViewPat p)
295 -- because of the way we're arranging the recursive calls,
296 -- this will be in the right context
297 ; (expr', fv_expr) <- rnLExpr expr
298 ; (res, fvs_res) <- rnLPatAndThen var pat $ \ pat' ->
299 lcont (ViewPat expr' pat' ty)
300 ; return (res, fvs_res `plusFV` fv_expr) }
303 pat@(QuasiQuotePat _) -> pprPanic "Can't do QuasiQuotePat without GHCi" (ppr p)
305 QuasiQuotePat qq -> do
306 (qq', _) <- rnQuasiQuote qq
307 pat' <- runQuasiQuotePat qq'
308 rnLPatAndThen var pat' $ \ (L _ pat'') ->
312 ConPatIn con stuff ->
313 -- rnConPatAndThen takes care of reconstructing the pattern
314 rnConPatAndThen var con stuff cont
317 rnLPatsAndThen var pats $ \ patslist ->
318 lcont (ListPat patslist placeHolderType)
321 do { (res, res_fvs) <- rnLPatsAndThen var pats $ \ patslist ->
322 lcont (PArrPat patslist placeHolderType)
323 ; return (res, res_fvs `plusFV` implicit_fvs) }
325 implicit_fvs = mkFVs [lengthPName, indexPName]
327 TuplePat pats boxed _ ->
328 do { checkTupSize (length pats)
329 ; rnLPatsAndThen var pats $ \ patslist ->
330 lcont (TuplePat patslist boxed placeHolderType) }
333 do { (name', fvs1) <- rnHsTypeFVs (text "In a type pattern") name
334 ; (res, fvs2) <- lcont (TypePat name')
335 ; return (res, fvs1 `plusFV` fvs2) }
338 -- helper for renaming constructor patterns
339 rnConPatAndThen :: NameMaker
340 -> Located RdrName -- the constructor
341 -> HsConPatDetails RdrName
342 -> (LPat Name -> RnM (a, FreeVars)) -- what to do afterwards
345 rnConPatAndThen var (con@(L loc _)) (PrefixCon pats) cont
346 = do { con' <- lookupLocatedOccRn con
347 ; (res, res_fvs) <- rnLPatsAndThen var pats $ \ pats' ->
348 cont (L loc $ ConPatIn con' (PrefixCon pats'))
349 ; return (res, res_fvs `addOneFV` unLoc con') }
351 rnConPatAndThen var (con@(L loc _)) (InfixCon pat1 pat2) cont
352 = do { con' <- lookupLocatedOccRn con
353 ; (res, res_fvs) <- rnLPatAndThen var pat1 $ \ pat1' ->
354 rnLPatAndThen var pat2 $ \ pat2' ->
355 do { fixity <- lookupFixityRn (unLoc con')
356 ; pat' <- mkConOpPatRn con' fixity pat1' pat2'
357 ; cont (L loc pat') }
358 ; return (res, res_fvs `addOneFV` unLoc con') }
360 rnConPatAndThen var (con@(L loc _)) (RecCon rpats) cont
361 = do { con' <- lookupLocatedOccRn con
362 ; (res, res_fvs) <- rnHsRecFieldsAndThen_Pattern con' var rpats $ \ rpats' ->
363 cont (L loc $ ConPatIn con' (RecCon rpats'))
364 ; return (res, res_fvs `addOneFV` unLoc con') }
366 -- what kind of record expression we're doing
367 -- the first two tell the name of the datatype constructor in question
368 -- and give a way of creating a variable to fill in a ..
369 data RnHsRecFieldsChoice a = Constructor (Located Name) (RdrName -> a)
370 | Pattern (Located Name) (RdrName -> a)
373 choiceToMessage (Constructor _ _) = "construction"
374 choiceToMessage (Pattern _ _) = "pattern"
375 choiceToMessage Update = "update"
377 doDotDot (Constructor a b) = Just (a,b)
378 doDotDot (Pattern a b) = Just (a,b)
379 doDotDot Update = Nothing
381 getChoiceName (Constructor n _) = Just n
382 getChoiceName (Pattern n _) = Just n
383 getChoiceName (Update) = Nothing
387 -- helper for renaming record patterns;
388 -- parameterized so that it can also be used for expressions
389 rnHsRecFieldsAndThen :: RnHsRecFieldsChoice field
390 -- how to rename the fields (CPSed)
391 -> (Located field -> (Located field' -> RnM (c, FreeVars))
392 -> RnM (c, FreeVars))
394 -> HsRecFields RdrName (Located field)
395 -- what to do in the scope of the field vars
396 -> (HsRecFields Name (Located field') -> RnM (c, FreeVars))
398 -- Haddock comments for record fields are renamed to Nothing here
399 rnHsRecFieldsAndThen choice rn_thing (HsRecFields fields dd) cont =
402 -- helper to collect and report duplicate record fields
403 reportDuplicateFields doingstr fields =
405 -- each list represents a RdrName that occurred more than once
406 -- (the list contains all occurrences)
407 -- invariant: each list in dup_fields is non-empty
408 dup_fields :: [[RdrName]]
409 (_, dup_fields) = removeDups compare
410 (map (unLoc . hsRecFieldId) fields)
412 -- duplicate field reporting function
413 field_dup_err dup_group = addErr (dupFieldErr doingstr (head dup_group))
415 mapM_ field_dup_err dup_fields
417 -- helper to rename each field
418 rn_field pun_ok (HsRecField field inside pun) cont = do
419 fieldname <- lookupRecordBndr (getChoiceName choice) field
420 checkErr (not pun || pun_ok) (badPun field)
421 (res, res_fvs) <- rn_thing inside $ \ inside' ->
422 cont (HsRecField fieldname inside' pun)
423 return (res, res_fvs `addOneFV` unLoc fieldname)
425 -- Compute the extra fields to be filled in by the dot-dot notation
426 dot_dot_fields fs con mk_field cont = do
427 con_fields <- lookupConstructorFields (unLoc con)
428 let missing_fields = con_fields `minusList` fs
429 loc <- getSrcSpanM -- Rather approximate
430 -- it's important that we make the RdrName fields that we morally wrote
431 -- and then rename them in the usual manner
432 -- (rather than trying to make the result of renaming directly)
433 -- because, for patterns, renaming can bind vars in the continuation
435 (map (L loc . mk_field . mkRdrUnqual . getOccName) missing_fields) $
437 let new_fs = [ HsRecField (L loc f) r False
438 | (f, r) <- missing_fields `zip` rhss ]
443 -- report duplicate fields
444 let doingstr = choiceToMessage choice
445 reportDuplicateFields doingstr fields
447 -- rename the records as written
448 -- check whether punning (implicit x=x) is allowed
449 pun_flag <- doptM Opt_RecordPuns
451 mapFvRnCPS (rn_field pun_flag) fields $ \ fields1 ->
455 Nothing -> cont (HsRecFields fields1 dd)
456 Just n -> ASSERT( n == length fields ) do
457 dd_flag <- doptM Opt_RecordWildCards
458 checkErr dd_flag (needFlagDotDot doingstr)
459 let fld_names1 = map (unLoc . hsRecFieldId) fields1
460 case doDotDot choice of
461 Nothing -> do addErr (badDotDot doingstr)
462 -- we return a junk value here so that error reporting goes on
463 cont (HsRecFields fields1 dd)
464 Just (con, mk_field) ->
465 dot_dot_fields fld_names1 con mk_field $
467 cont (HsRecFields (fields1 ++ fields2) dd)
469 needFlagDotDot str = vcat [ptext SLIT("Illegal `..' in record") <+> text str,
470 ptext SLIT("Use -XRecordWildCards to permit this")]
472 badDotDot str = ptext SLIT("You cannot use `..' in record") <+> text str
474 badPun fld = vcat [ptext SLIT("Illegal use of punning for field") <+> quotes (ppr fld),
475 ptext SLIT("Use -XRecordPuns to permit this")]
479 rnHsRecFieldsAndThen_Pattern :: Located Name
480 -> NameMaker -- new name maker
481 -> HsRecFields RdrName (LPat RdrName)
482 -> (HsRecFields Name (LPat Name) -> RnM (c, FreeVars))
484 rnHsRecFieldsAndThen_Pattern n var
485 = rnHsRecFieldsAndThen (Pattern n VarPat) (rnLPatAndThen var)
488 -- wrapper to use rnLExpr in CPS style;
489 -- because it does not bind any vars going forward, it does not need
490 -- to be written that way
491 rnLExprAndThen :: (LHsExpr RdrName -> RnM (LHsExpr Name, FreeVars))
493 -> (LHsExpr Name -> RnM (c, FreeVars))
495 rnLExprAndThen f e cont = do { (x, fvs1) <- f e
496 ; (res, fvs2) <- cont x
497 ; return (res, fvs1 `plusFV` fvs2) }
500 -- non-CPSed because exprs don't leave anything bound
501 rnHsRecFields_Con :: Located Name
502 -> (LHsExpr RdrName -> RnM (LHsExpr Name, FreeVars))
503 -> HsRecFields RdrName (LHsExpr RdrName)
504 -> RnM (HsRecFields Name (LHsExpr Name), FreeVars)
505 rnHsRecFields_Con n rnLExpr fields = rnHsRecFieldsAndThen (Constructor n HsVar)
506 (rnLExprAndThen rnLExpr) fields $ \ res ->
507 return (res, emptyFVs)
509 rnHsRecFields_Update :: (LHsExpr RdrName -> RnM (LHsExpr Name, FreeVars))
510 -> HsRecFields RdrName (LHsExpr RdrName)
511 -> RnM (HsRecFields Name (LHsExpr Name), FreeVars)
512 rnHsRecFields_Update rnLExpr fields = rnHsRecFieldsAndThen Update
513 (rnLExprAndThen rnLExpr) fields $ \ res ->
514 return (res, emptyFVs)
519 %************************************************************************
521 \subsubsection{Literals}
523 %************************************************************************
525 When literals occur we have to make sure
526 that the types and classes they involve
530 rnLit :: HsLit -> RnM ()
531 rnLit (HsChar c) = checkErr (inCharRange c) (bogusCharError c)
532 rnLit other = return ()
534 rnOverLit (HsIntegral i _ _) = do
535 (from_integer_name, fvs) <- lookupSyntaxName fromIntegerName
537 return (HsIntegral i from_integer_name placeHolderType, fvs)
539 extra_fvs = mkFVs [plusIntegerName, timesIntegerName]
540 -- Big integer literals are built, using + and *,
541 -- out of small integers (DsUtils.mkIntegerLit)
542 -- [NB: plusInteger, timesInteger aren't rebindable...
543 -- they are used to construct the argument to fromInteger,
544 -- which is the rebindable one.]
546 return (HsIntegral i from_integer_name placeHolderType, fvs `plusFV` extra_fvs)
548 rnOverLit (HsFractional i _ _) = do
549 (from_rat_name, fvs) <- lookupSyntaxName fromRationalName
551 extra_fvs = mkFVs [ratioDataConName, plusIntegerName, timesIntegerName]
552 -- We have to make sure that the Ratio type is imported with
553 -- its constructor, because literals of type Ratio t are
554 -- built with that constructor.
555 -- The Rational type is needed too, but that will come in
556 -- as part of the type for fromRational.
557 -- The plus/times integer operations may be needed to construct the numerator
558 -- and denominator (see DsUtils.mkIntegerLit)
559 return (HsFractional i from_rat_name placeHolderType, fvs `plusFV` extra_fvs)
561 rnOverLit (HsIsString s _ _) = do
562 (from_string_name, fvs) <- lookupSyntaxName fromStringName
563 return (HsIsString s from_string_name placeHolderType, fvs)
566 %************************************************************************
568 \subsubsection{Quasiquotation}
570 %************************************************************************
572 See Note [Quasi-quote overview] in TcSplice.
575 rnQuasiQuote :: HsQuasiQuote RdrName -> RnM (HsQuasiQuote Name, FreeVars)
576 rnQuasiQuote (HsQuasiQuote n quoter quoteSpan quote)
577 = do { loc <- getSrcSpanM
578 ; [n'] <- newLocalsRn [L loc n]
579 ; quoter' <- (lookupOccRn quoter)
580 -- If 'quoter' is not in scope, proceed no further
581 -- Otherwise lookupOcc adds an error messsage and returns
582 -- an "unubound name", which makes the subsequent attempt to
583 -- run the quote fail
584 ; return (HsQuasiQuote n' quoter' quoteSpan quote, unitFV quoter') }
587 %************************************************************************
589 \subsubsection{Errors}
591 %************************************************************************
594 checkTupSize :: Int -> RnM ()
595 checkTupSize tup_size
596 | tup_size <= mAX_TUPLE_SIZE
599 = addErr (sep [ptext SLIT("A") <+> int tup_size <> ptext SLIT("-tuple is too large for GHC"),
600 nest 2 (parens (ptext SLIT("max size is") <+> int mAX_TUPLE_SIZE)),
601 nest 2 (ptext SLIT("Workaround: use nested tuples or define a data type"))])
604 = (ptext SLIT("Illegal signature in pattern:") <+> ppr ty)
605 $$ nest 4 (ptext SLIT("Use -XPatternSignatures to permit it"))
608 = hsep [ptext SLIT("duplicate field name"),
610 ptext SLIT("in record"), text str]
613 = ptext SLIT("character literal out of range: '\\") <> char c <> char '\''
615 badViewPat pat = vcat [ptext SLIT("Illegal view pattern: ") <+> ppr pat,
616 ptext SLIT("Use -XViewPatterns to enalbe view patterns")]