Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #1347 by ignoring generically typed symbols on printing C #1373

Merged
merged 2 commits into from
Jan 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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