Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,322
Issues
4,322
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
362
Merge Requests
362
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
29e3d7b1
Commit
29e3d7b1
authored
Mar 18, 2012
by
Iavor S. Diatchki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only parse type literals when using `DataKinds`.
parent
5e10022d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
2 deletions
+22
-2
compiler/parser/Lexer.x
compiler/parser/Lexer.x
+6
-0
compiler/parser/Parser.y.pp
compiler/parser/Parser.y.pp
+2
-2
compiler/parser/RdrHsSyn.lhs
compiler/parser/RdrHsSyn.lhs
+14
-0
No files found.
compiler/parser/Lexer.x
View file @
29e3d7b1
...
...
@@ -56,6 +56,7 @@ module Lexer (
getLexState, popLexState, pushLexState,
extension, bangPatEnabled, datatypeContextsEnabled,
traditionalRecordSyntaxEnabled,
typeLiteralsEnabled,
addWarning,
lexTokenStream
) where
...
...
@@ -1806,6 +1807,8 @@ safeHaskellBit :: Int
safeHaskellBit = 26
traditionalRecordSyntaxBit :: Int
traditionalRecordSyntaxBit = 27
typeLiteralsBit :: Int
typeLiteralsBit = 28
always :: Int -> Bool
always _ = True
...
...
@@ -1849,6 +1852,8 @@ nondecreasingIndentation :: Int -> Bool
nondecreasingIndentation flags = testBit flags nondecreasingIndentationBit
traditionalRecordSyntaxEnabled :: Int -> Bool
traditionalRecordSyntaxEnabled flags = testBit flags traditionalRecordSyntaxBit
typeLiteralsEnabled :: Int -> Bool
typeLiteralsEnabled flags = testBit flags typeLiteralsBit
-- PState for parsing options pragmas
--
...
...
@@ -1908,6 +1913,7 @@ mkPState flags buf loc =
.|. nondecreasingIndentationBit `setBitIf` xopt Opt_NondecreasingIndentation flags
.|. safeHaskellBit `setBitIf` safeImportsOn flags
.|. traditionalRecordSyntaxBit `setBitIf` xopt Opt_TraditionalRecordSyntax flags
.|. typeLiteralsBit `setBitIf` xopt Opt_DataKinds flags
--
setBitIf :: Int -> Bool -> Int
b `setBitIf` cond | cond = bit b
...
...
compiler/parser/Parser.y.pp
View file @
29e3d7b1
...
...
@@ -1080,8 +1080,8 @@ atype :: { LHsType RdrName }
|
SIMPLEQUOTE
'('
ctype
','
comma_types1
')'
{
LL
$
HsExplicitTupleTy
[]
(
$3
:
$5
)
}
|
SIMPLEQUOTE
'['
comma_types0
']'
{
LL
$
HsExplicitListTy
placeHolderKind
$3
}
|
'['
ctype
','
comma_types1
']'
{
LL
$
HsExplicitListTy
placeHolderKind
(
$2
:
$4
)
}
|
INTEGER
{
LL
$
HsTyLit
$
HsNumTy
$
getINTEGER
$1
}
|
STRING
{
LL
$
HsTyLit
$
HsStrTy
$
getSTRING
$1
}
|
INTEGER
{
%
mkTyLit
$
LL
$
HsNumTy
$
getINTEGER
$1
}
|
STRING
{
%
mkTyLit
$
LL
$
HsStrTy
$
getSTRING
$1
}
--
An
inst_type
is
what
occurs
in
the
head
of
an
instance
decl
--
e
.
g
.
(
Foo
a
,
Gaz
b
)
=>
Wibble
a
b
...
...
compiler/parser/RdrHsSyn.lhs
View file @
29e3d7b1
...
...
@@ -14,6 +14,7 @@ module RdrHsSyn (
mkClassDecl, mkTyData, mkTyFamily, mkTySynonym,
splitCon, mkInlinePragma,
mkRecConstrOrUpdate, -- HsExp -> [HsFieldUpdate] -> P HsExp
mkTyLit,
cvBindGroup,
cvBindsAndSigs,
...
...
@@ -250,6 +251,19 @@ mkTopSpliceDecl :: LHsExpr RdrName -> HsDecl RdrName
mkTopSpliceDecl (L _ (HsQuasiQuoteE qq)) = QuasiQuoteD qq
mkTopSpliceDecl (L _ (HsSpliceE (HsSplice _ expr))) = SpliceD (SpliceDecl expr Explicit)
mkTopSpliceDecl other_expr = SpliceD (SpliceDecl other_expr Implicit)
mkTyLit :: Located (HsTyLit) -> P (LHsType RdrName)
mkTyLit l =
do allowed <- extension typeLiteralsEnabled
if allowed
then return (HsTyLit `fmap` l)
else parseErrorSDoc (getLoc l)
(text "Illegal literal in type (use -XDataKinds to enable):" <+>
ppr l)
\end{code}
%************************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment