[Git][ghc/ghc][wip/T26503] [ci skip] wip
Brandon Chinn pushed to branch wip/T26503 at Glasgow Haskell Compiler / GHC Commits: 70cb4e7e by Brandon Chinn at 2025-10-14T21:29:53-07:00 [ci skip] wip - - - - - 4 changed files: - compiler/GHC/Hs/Lit.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Types.hs - libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs Changes: ===================================== compiler/GHC/Hs/Lit.hs ===================================== @@ -38,6 +38,7 @@ import GHC.Utils.Panic (panic) import GHC.Hs.Extension import Language.Haskell.Syntax.Expr ( HsExpr ) import Language.Haskell.Syntax.Extension +import Language.Haskell.Syntax.Module.Name (ModuleName) import Language.Haskell.Syntax.Lit {- @@ -87,6 +88,7 @@ instance Eq HsLitTc where data HsStringMeta = HsStringMeta { strMetaSourceText :: SourceText , strMetaMultiline :: Bool + , strMetaQualified :: Maybe ModuleName } deriving (Data) ===================================== compiler/GHC/Parser.y ===================================== @@ -4148,6 +4148,17 @@ literal :: { Located (HsLit GhcPs) } $ getPRIMSTRING $1 } | PRIMFLOAT { sL1 $1 $ HsFloatPrim noExtField $ getPRIMFLOAT $1 } | PRIMDOUBLE { sL1 $1 $ HsDoublePrim noExtField $ getPRIMDOUBLE $1 } + | modid '.' STRING { hintQualifiedStrings *> + sLL $1 $2 + (HsString + (defaultStrMeta (getSTRINGs $1)) + (getSTRING $1)) } + | modid '.' STRING_MULTI { hintQualifiedStrings *> + hintMultilineStrings *> + sLL $1 $2 + (HsString + (defaultStrMeta (getSTRINGMULTIs $1)){strMetaMultiline = True} + (getSTRING $1)) } ----------------------------------------------------------------------------- -- Layout @@ -4505,6 +4516,18 @@ hintQualifiedDo tok = do ITmdo (Just m) -> Just $ ftext m <> text ".mdo" t -> Nothing +-- Hint about the MultilineStrings extension +hintMultilineStrings :: SrcSpan -> P () +hintMultilineStrings span = do + enabled <- getBit MultilineStringsBit + unless enabled $ addError $ mkPlainErrorMsgEnvelope span PsErrMultilineStrings + +-- Hint about the QualifiedStrings extension +hintQualifiedStrings :: SrcSpan -> P () +hintQualifiedStrings span = do + enabled <- getBit QualifiedStringsBit + unless enabled $ addError $ mkPlainErrorMsgEnvelope span PsErrQualifiedStrings + -- When two single quotes don't followed by tyvar or gtycon, we report the -- error as empty character literal, or TH quote that missing proper type -- variable or constructor. See #13450. ===================================== compiler/GHC/Parser/Errors/Types.hs ===================================== @@ -441,6 +441,12 @@ data PsMessage -- | Multi-way if-expression found but MultiWayIf not enabled | PsErrMultiWayIf + -- | Multiline string literal found but MultilineStrings not enabled + | PsErrMultilineStrings + + -- | Qualified string literal found but QualifiedStrings not enabled + | PsErrQualifiedStrings + -- | Explicit forall found but no extension allowing it is enabled | PsErrExplicitForall !Bool -- ^ is Unicode forall? ===================================== libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs ===================================== @@ -696,6 +696,7 @@ data Lit = CharL Char -- ^ @\'c\'@ | StringPrimL [Word8] -- ^ @"string"#@. A primitive C-style string, type 'Addr#' | BytesPrimL Bytes -- ^ Some raw bytes, type 'Addr#': | CharPrimL Char -- ^ @\'c\'#@ + | QualStringL ModName String -- ^ @M."string"#@ deriving( Show, Eq, Ord, Generic ) -- We could add Int, Float, Double etc, as we do in HsLit, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/70cb4e7e79a377a75119e019d7b64d91... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/70cb4e7e79a377a75119e019d7b64d91... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Brandon Chinn (@brandonchinn178)