Skip to content

Commit

Permalink
fix: #1347 by ignoring generically typed symbols on printing C (#1373)
Browse files Browse the repository at this point in the history
* fix: #1347 by introducing predicate

* fix: simplify emission check in primitives (thanks @eriksvedang)
  • Loading branch information
hellerve committed Jan 10, 2022
1 parent 330dc52 commit 027d8b3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Primitives.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Control.Applicative
import Control.Monad (foldM, unless, when)
import Control.Monad.IO.Class (MonadIO, liftIO)
import Data.Bifunctor
import Data.Either (fromRight, rights)
import Data.Either (fromRight, isRight, rights)
import Data.Functor ((<&>))
import Data.List (foldl')
import Data.Maybe (fromJust, fromMaybe)
Expand Down Expand Up @@ -182,10 +182,12 @@ define hidden ctx qualifiedXObj =
defineInTypeEnv = pure . fromRight ctx . (insertTypeBinder ctx qpath)
defineInGlobalEnv :: Binder -> IO Context
defineInGlobalEnv newBinder =
when (projectEchoC (contextProj ctx)) (putStrLn (toC All (Binder emptyMeta annXObj)))
when (projectEchoC (contextProj ctx) && canBeEmitted annXObj) (putStrLn (toC All (Binder emptyMeta annXObj)))
>> case (lookupBinderInGlobalEnv ctx qpath) of
Left _ -> pure (fromRight ctx (insertInGlobalEnv ctx qpath newBinder))
Right oldBinder -> redefineExistingBinder oldBinder newBinder
canBeEmitted :: XObj -> Bool
canBeEmitted x = isRight (checkForUnresolvedSymbols x)
redefineExistingBinder :: Binder -> Binder -> IO Context
redefineExistingBinder old@(Binder meta _) (Binder _ x) =
do
Expand Down

0 comments on commit 027d8b3

Please sign in to comment.