From af47beea06a467bb8897861ba3d2c2a54b00e5f2 Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Mon, 20 Nov 2023 09:58:35 -0800 Subject: [PATCH] Don't do subtype matching for docs and terms or we'll match fully polymorphic terms. --- unison-share-api/src/Unison/Server/Backend.hs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/unison-share-api/src/Unison/Server/Backend.hs b/unison-share-api/src/Unison/Server/Backend.hs index 1f6727aedd..08c5e7319e 100644 --- a/unison-share-api/src/Unison/Server/Backend.hs +++ b/unison-share-api/src/Unison/Server/Backend.hs @@ -491,11 +491,11 @@ isDoc codebase ref = do isDoc' :: (Var v, Monoid loc) => Maybe (Type v loc) -> Bool isDoc' typeOfTerm = do - -- A term is a dococ if its type conforms to the `Doc` type. + -- A term is a doc if its type conforms to the `Doc` type. case typeOfTerm of Just t -> - Typechecker.isSubtype t doc1Type - || Typechecker.isSubtype t doc2Type + Typechecker.isEqual t doc1Type + || Typechecker.isEqual t doc2Type Nothing -> False doc1Type :: (Ord v, Monoid a) => Type v a @@ -507,7 +507,7 @@ doc2Type = Type.ref mempty DD.doc2Ref isTestResultList :: forall v a. (Var v, Monoid a) => Maybe (Type v a) -> Bool isTestResultList typ = case typ of Nothing -> False - Just t -> Typechecker.isSubtype t resultListType + Just t -> Typechecker.isEqual t resultListType resultListType :: (Ord v, Monoid a) => Type v a resultListType = Type.app mempty (Type.list mempty) (Type.ref mempty Decls.testResultRef) @@ -553,15 +553,11 @@ getTermTag :: m TermTag getTermTag codebase r sig = do -- A term is a doc if its type conforms to the `Doc` type. - let isDoc = case sig of - Just t -> - Typechecker.isSubtype t (Type.ref mempty Decls.docRef) - || Typechecker.isSubtype t (Type.ref mempty DD.doc2Ref) - Nothing -> False + let isDoc = isDoc' sig -- A term is a test if it has the type [test.Result] let isTest = case sig of Just t -> - Typechecker.isSubtype t (Decls.testResultType mempty) + Typechecker.isEqual t (Decls.testResultType mempty) Nothing -> False constructorType <- case r of V2Referent.Ref {} -> pure Nothing @@ -1012,7 +1008,7 @@ docsForDefinitionName codebase (NameSearch {termSearch}) name = do Referent.Ref r -> maybe [] (pure . (r,)) <$> Codebase.getTypeOfTerm codebase r _ -> pure [] - pure [r | (r, t) <- rts, Typechecker.isSubtype t (Type.ref mempty DD.doc2Ref)] + pure [r | (r, t) <- rts, isDoc' (Just t)] -- | Evaluate and render the given docs renderDocRefs ::