summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-11-24 10:52:56 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2021-11-24 10:55:02 +0000
commitce9d50003783601b922134e838c3115b1e9c6a94 (patch)
treed3d011b1798b5eb17d98489d7e6814b3701d9f83
parent9dcb2ad15df54e209cfae3dd1f51cf8e8d6c69d5 (diff)
downloadhaskell-wip/t20723.tar.gz
Allow keywords which can be used as variables to be used with OverloadedDotSyntaxwip/t20723
There are quite a few keywords which are allowed to be used as variables. Such as "as", "dependency" etc. These weren't accepted by OverloadedDotSyntax. The fix is pretty simple, use the varid production rather than raw VARID. Fixes #20723
-rw-r--r--compiler/GHC/Parser.y2
-rw-r--r--testsuite/tests/overloadedrecflds/should_compile/T20723.hs9
-rw-r--r--testsuite/tests/overloadedrecflds/should_compile/all.T1
3 files changed, 11 insertions, 1 deletions
diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y
index 3575ee8eee..d499341c36 100644
--- a/compiler/GHC/Parser.y
+++ b/compiler/GHC/Parser.y
@@ -3720,7 +3720,7 @@ qvar :: { LocatedN RdrName }
-- *after* we see the close paren.
field :: { Located FastString }
- : VARID { sL1 $1 $! getVARID $1 }
+ : varid { reLocN $ fmap (occNameFS . rdrNameOcc) $1 }
qvarid :: { LocatedN RdrName }
: varid { $1 }
diff --git a/testsuite/tests/overloadedrecflds/should_compile/T20723.hs b/testsuite/tests/overloadedrecflds/should_compile/T20723.hs
new file mode 100644
index 0000000000..06a5db988f
--- /dev/null
+++ b/testsuite/tests/overloadedrecflds/should_compile/T20723.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE OverloadedRecordDot #-}
+module T20723 where
+
+data Rec = Rec { as :: Int, dependency :: Int, signature :: Int, javascript :: Int }
+
+res r = r.as + r.dependency + r.signature + r.javascript
+
+
+
diff --git a/testsuite/tests/overloadedrecflds/should_compile/all.T b/testsuite/tests/overloadedrecflds/should_compile/all.T
index b52c43a655..863fbacca8 100644
--- a/testsuite/tests/overloadedrecflds/should_compile/all.T
+++ b/testsuite/tests/overloadedrecflds/should_compile/all.T
@@ -9,4 +9,5 @@ test('NFSImport', [extra_files(['NFSExport.hs'])], multimod_compile, ['NFSImport
test('T18999_NoFieldSelectors', normal, compile, [''])
test('T18999_FieldSelectors', normal, compile, [''])
test('T19154', normal, compile, [''])
+test('T20723', normal, compile, [''])