diff --git a/CHANGELOG.md b/CHANGELOG.md index 426fbf961a7a39956744b45adf8d2cfb7477cbf0..5b88d76f34480f433e50b3d00d69729b43abeba6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Version 1.0.2 (under development) ============= * Fixed bug with wrong type of free variables in the intermediate language. + * Fixed bug with generated default implementations of nullary class methods. Version 1.0.1 ============= diff --git a/src/Transformations/Dictionary.hs b/src/Transformations/Dictionary.hs index e74c0e122d7efbccb41a4ac773321369abb582a3..854cd41026fa47ef7644339f9965e3c62b50649d 100644 --- a/src/Transformations/Dictionary.hs +++ b/src/Transformations/Dictionary.hs @@ -413,10 +413,12 @@ defaultClassMethodDecl :: QualIdent -> Ident -> DTM (Decl PredType) defaultClassMethodDecl cls f = do pty@(PredType _ ty) <- getClassMethodType cls f augEnv <- getAugEnv - let pats = if isAugmented augEnv (qualifyLike cls f) + let augmented = isAugmented augEnv (qualifyLike cls f) + pats = if augmented then [ConstructorPattern predUnitType qUnitId []] else [] - return $ funDecl NoPos pty f pats $ preludeError (instType ty) $ + ty' = if augmented then arrowBase ty else ty + return $ funDecl NoPos pty f pats $ preludeError (instType ty') $ "No instance or default method for class operation " ++ escName f getClassMethodType :: QualIdent -> Ident -> DTM PredType