Skip to content
Snippets Groups Projects
Commit b17fb3d9 authored by sheaf's avatar sheaf Committed by Marge Bot
Browse files

Don't allow . in overloaded labels

This patch removes . from the list of allowed characters in a non-quoted
overloaded label, as it was realised this steals syntax, e.g. (#.).

Users who want this functionality will have to add quotes around the
label, e.g. `#"17.28"`.

Fixes #22821
parent 3e09cf82
No related branches found
No related tags found
No related merge requests found
......@@ -163,7 +163,6 @@ $small = [$ascsmall $unismall \_]
$uniidchar = \x07 -- Trick Alex into handling Unicode. See Note [Unicode in Alex].
$idchar = [$small $large $digit $uniidchar \']
$labelchar = [$small $large $digit $uniidchar \' \.]
$unigraphic = \x06 -- Trick Alex into handling Unicode. See Note [Unicode in Alex].
$graphic = [$small $large $symbol $digit $idchar $special $unigraphic \"\']
......@@ -455,7 +454,7 @@ $unigraphic / { isSmartQuote } { smart_quote_error }
}
<0> {
"#" $labelchar+ / { ifExtension OverloadedLabelsBit } { skip_one_varid_src ITlabelvarid }
"#" $idchar+ / { ifExtension OverloadedLabelsBit } { skip_one_varid_src ITlabelvarid }
"#" \" / { ifExtension OverloadedLabelsBit } { lex_quoted_label }
}
......
......@@ -84,7 +84,7 @@ Language
This extends the variety syntax for constructing labels under :extension:`OverloadedLabels`.
Examples of newly allowed syntax:
- Leading capital letters: `#Foo` equivalant to `getLabel @"Foo"`
- Numeric characters: `#3.14` equivalent to `getLabel @"3.14"`
- Numeric characters: `#1728` equivalent to `getLabel @"1728"`
- Arbitrary strings: `#"Hello, World!"` equivalent to `getLabel @"Hello, World!"`
Compiler
......
......@@ -12,8 +12,9 @@ import GHC.Prim (Addr#)
instance KnownSymbol symbol => IsLabel symbol String where
fromLabel = symbolVal (Proxy :: Proxy symbol)
(#) :: String -> Int -> String
(#), (#.) :: String -> Int -> String
(#) _ i = show i
_ #. i = show i
f :: Addr# -> Int -> String
f _ i = show i
......@@ -26,13 +27,13 @@ main = traverse_ putStrLn
, #type
, #Foo
, #3
, #199.4
, #"199.4"
, #17a23b
, #f'a'
, #'a'
, #'
, #''notTHSplice
, #...
, #"..."
, #привет
, #こんにちは
, #"3"
......
......@@ -14,8 +14,9 @@ import GHC.Prim (Addr#)
instance KnownSymbol symbol => IsLabel symbol String where
fromLabel = symbolVal (Proxy :: Proxy symbol)
(#) :: String -> Int -> String
(#), (#.) :: String -> Int -> String
(#) _ i = show i
_ #. i = show i
f :: Addr# -> Int -> String
f _ i = show i
......@@ -28,13 +29,13 @@ main = traverse_ putStrLn
, #type
, #Foo
, #3
, #199.4
, #"199.4"
, #17a23b
, #f'a'
, #'a'
, #'
, #''notTHSplice
, #...
, #"..."
, #привет
, #こんにちは
, #"3"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment