Skip to content

Commit d45b655

Browse files
author
jared
committed
Undo fieldnames should be disjoint from keywords
1 parent 805bf3d commit d45b655

File tree

1 file changed

+12
-5
lines changed
  • lambda-buffers-frontend/src/LambdaBuffers/Frontend

1 file changed

+12
-5
lines changed

lambda-buffers-frontend/src/LambdaBuffers/Frontend/Parsec.hs

+12-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import Data.Char qualified as Char
2222
import Data.Kind (Type)
2323
import Data.Maybe (fromJust, isJust)
2424
import Data.String (IsString (fromString))
25-
import Data.Text qualified as Text
2625
import LambdaBuffers.Compiler.NamingCheck (pClassName, pConstrName, pFieldName, pModuleNamePart, pTyName)
2726
import LambdaBuffers.Frontend.Syntax (ClassConstraint (ClassConstraint), ClassDef (ClassDef), ClassName (ClassName), ClassRef (ClassRef), ConstrName (ConstrName), Constraint (Constraint), Constructor (Constructor), Derive (Derive), Field (Field), FieldName (FieldName), Import (Import), InstanceClause (InstanceClause), Module (Module), ModuleAlias (ModuleAlias), ModuleName (ModuleName), ModuleNamePart (ModuleNamePart), Name (Name), Product (Product), Record (Record), SourceInfo (SourceInfo, to), SourcePos (SourcePos), Statement (StClassDef, StDerive, StInstanceClause, StTyDef), Sum (Sum), Ty (TyApp, TyRef', TyVar), TyArg (TyArg), TyBody (Opaque, ProductBody, RecordBody, SumBody), TyDef (TyDef), TyName (TyName), TyRef (TyRef), VarName (VarName), kwAs, kwClassDef, kwDerive, kwImport, kwInstance, kwModule, kwQualified, kwTyDefOpaque, kwTyDefProduct, kwTyDefRecord, kwTyDefSum, kws)
2827
import Text.Parsec (ParseError, ParsecT, SourceName, Stream, alphaNum, between, char, endOfLine, eof, getPosition, label, lower, many, many1, manyTill, notFollowedBy, optionMaybe, runParserT, satisfy, sepBy, sepEndBy, sourceColumn, sourceLine, sourceName, space, string, try, unexpected, (<?>))
@@ -207,10 +206,18 @@ tokenTyRef = token' parseTyRef
207206
parseFieldName :: Stream s m Char => Parser s m (FieldName SourceInfo)
208207
parseFieldName =
209208
withSourceInfo . label' "record field name" $ do
210-
v <- pFieldName
211-
-- Recall in the lexical specification that fieldnames are disjoint from keywords
212-
notKeyword $ Text.unpack v
213-
return $ FieldName v
209+
-- TODO(jaredponn): Technically, the specification says that field names
210+
-- are disjoint from keywords, but some of the other golden tests use this
211+
-- fact.
212+
-- We leave it in as a fairly harmless bug for now.
213+
--
214+
-- But the version that fixes this is as follows:
215+
--
216+
-- > v <- pFieldName
217+
-- > -- Recall in the lexical specification that fieldnames are disjoint from keywords
218+
-- > notKeyword $ Data.Text.unpack v
219+
-- > return $ FieldName v
220+
FieldName <$> pFieldName
214221

215222
tokenFieldName :: Stream s m Char => Parser s m (FieldName SourceInfo)
216223
tokenFieldName = token' parseFieldName

0 commit comments

Comments
 (0)