on master help sign in
Fix TH bug when deriving ToJSON1/2 or FromJSON1/2 for types that don't mention the parameter
commitdc3e070d1af4e6f8f7f1e5af56b129226cadb4c9 authorRyan Scott <ryan.gl.scott@gmail.com> dateSat 16 Jul 2016, 16:13 (10 years ago) parent3f4ff46
1 file changed+6−4
Data/Aeson/TH.hs+6−4
Data/Aeson/TH.hs+6−4
@@ -1408,10 +1408,12 @@ dispatchFunByType jc jf conName tvMap list ty = do
14081408 if any (`mentionsName` tyVarNames) lhsArgs
14091409 || itf && any (`mentionsName` tyVarNames) tyArgs
14101410 then outOfPlaceTyVarError jc conName
1411− else appsE $ varE (jsonFunValOrListName list jf $ toEnum numLastArgs)
1412− : zipWith (dispatchFunByType jc jf conName tvMap)
1413− (cycle [False,True])
1414− (interleave rhsArgs rhsArgs)
1411+ else if any (`mentionsName` tyVarNames) rhsArgs
1412+ then appsE $ varE (jsonFunValOrListName list jf $ toEnum numLastArgs)
1413+ : zipWith (dispatchFunByType jc jf conName tvMap)
1414+ (cycle [False,True])
1415+ (interleave rhsArgs rhsArgs)
1416+ else varE $ jsonFunValOrListName list jf Arity0
14151417
14161418dispatchToJSON, dispatchToEncoding, dispatchParseJSON
14171419 :: JSONClass -> Name -> TyVarMap -> Type -> Q Exp