Closed DoctorRyner closed 4 years ago
What's the error? What's the output of running record-dot-preprocessor over the file on the command line?
It happens only after encountering that syntax, as you can see test1 does work
Oh, sorry, my mistake, this is output
{-# LINE 1 "api/src/Route/Root.hs" #-}
{-# LANGUAGE DuplicateRecordFields, DataKinds, FlexibleInstances, TypeApplications, FlexibleContexts, MultiParamTypeClasses, OverloadedLabels #-}
{-# LINE 1 "api/src/Route/Root.hs" #-}
{-# OPTIONS_GHC -F -pgmF=record-dot-preprocessor #-}
module Route.Root where
import qualified GHC.Records.Extra as Z
{-# LINE 5 "api/src/Route/Root.hs" #-}
import Servant
import Types
handler :: AppM NoContent
handler = pure NoContent
data V3 a = V3 { x, y, z :: a }
test2 :: Int
test2 = (Z.getField @"x" (V3 0 0 0))
type Type = Get '[JSON] NoContent
test :: Int
test = (V3 0 0 0).x
instance Z.HasField "x" (V3 a) (a) where hasField _r = (\_x -> _r{x=_x}, (x :: (V3 a) -> a) _r)
instance Z.HasField "y" (V3 a) (a) where hasField _r = (\_x -> _r{y=_x}, (y :: (V3 a) -> a) _r)
instance Z.HasField "z" (V3 a) (a) where hasField _r = (\_x -> _r{z=_x}, (z :: (V3 a) -> a) _r)
_preprocessor_unused_Route_Root :: Z.HasField "" r a => r -> a;_preprocessor_unused_Route_Root = Z.getField @""
Thanks, the problem was the lexer thought '[JSON]
was the start of a character literal, and thus assumed the rest of the file was part of that literal. I've changed the lexer so that shouldn't happen, added a test and released 0.2.1.
Pragma doesn't work if dot syntax is encountered in this code, it treats it like unexistent