summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-11-24 10:52:56 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-26 16:02:23 -0500
commit02372be119bd1a4e7099d2c7d5bb3de096e99409 (patch)
tree6fe26c6bb54b56cd576f5dd43f3684ddefad0b7d
parent7e18b3041321b19876e74b88ffed3b44e4665c23 (diff)
downloadhaskell-02372be119bd1a4e7099d2c7d5bb3de096e99409.tar.gz
Allow keywords which can be used as variables to be used with OverloadedDotSyntax
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, [''])