From: Matthijs Kooijman Date: Wed, 10 Mar 2010 11:36:55 +0000 (+0100) Subject: Let classoperationresolution handle partially inlined dictionaries. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=db014de8ebda19a0828193c1230d0581bb923ce0;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Let classoperationresolution handle partially inlined dictionaries. Previously, if a dictionary argument was not yet an application of a dataconstructor (e.g., completely inlined) but an application of a polymorphic top level binder (e.g., $fsomething), then it would complain about mismatching types. --- diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index 86ade5b..2f056d7 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -416,7 +416,8 @@ classopresolution expr@(App (App (Var sel) ty) dict) = Nothing -> return expr Just cls -> case collectArgs dict of (_, []) -> return expr -- Dict is not an application (e.g., not inlined yet) - (dictdc, (ty':selectors)) | tyargs_neq ty ty' -> error $ "Applying class selector to dictionary without matching type?\n" ++ pprString expr + (Var dictdc, (ty':selectors)) | not (Maybe.isJust (Id.isDataConId_maybe dictdc)) -> return expr -- Dictionary is not a datacon yet (but e.g., a top level binder) + | tyargs_neq ty ty' -> error $ "Applying class selector to dictionary without matching type?\n" ++ pprString expr | otherwise -> let selector_ids = Class.classSelIds cls in -- Find the selector used in the class' list of selectors @@ -424,6 +425,7 @@ classopresolution expr@(App (App (Var sel) ty) dict) = Nothing -> error $ "Selector not found in class' selector list? This should not happen!\nExpression: " ++ pprString expr ++ "\nClass: " ++ show cls ++ "\nSelectors: " ++ show selector_ids -- Get the corresponding argument from the dictionary Just n -> change (selectors!!n) + (_, _) -> return expr -- Not applying a variable? Don't touch where -- Compare two type arguments, returning True if they are _not_ -- equal