Skip to content

Commit 027d8b3

Browse files
authored
fix: #1347 by ignoring generically typed symbols on printing C (#1373)
* fix: #1347 by introducing predicate * fix: simplify emission check in primitives (thanks @eriksvedang)
1 parent 330dc52 commit 027d8b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Primitives.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Control.Applicative
99
import Control.Monad (foldM, unless, when)
1010
import Control.Monad.IO.Class (MonadIO, liftIO)
1111
import Data.Bifunctor
12-
import Data.Either (fromRight, rights)
12+
import Data.Either (fromRight, isRight, rights)
1313
import Data.Functor ((<&>))
1414
import Data.List (foldl')
1515
import Data.Maybe (fromJust, fromMaybe)
@@ -182,10 +182,12 @@ define hidden ctx qualifiedXObj =
182182
defineInTypeEnv = pure . fromRight ctx . (insertTypeBinder ctx qpath)
183183
defineInGlobalEnv :: Binder -> IO Context
184184
defineInGlobalEnv newBinder =
185-
when (projectEchoC (contextProj ctx)) (putStrLn (toC All (Binder emptyMeta annXObj)))
185+
when (projectEchoC (contextProj ctx) && canBeEmitted annXObj) (putStrLn (toC All (Binder emptyMeta annXObj)))
186186
>> case (lookupBinderInGlobalEnv ctx qpath) of
187187
Left _ -> pure (fromRight ctx (insertInGlobalEnv ctx qpath newBinder))
188188
Right oldBinder -> redefineExistingBinder oldBinder newBinder
189+
canBeEmitted :: XObj -> Bool
190+
canBeEmitted x = isRight (checkForUnresolvedSymbols x)
189191
redefineExistingBinder :: Binder -> Binder -> IO Context
190192
redefineExistingBinder old@(Binder meta _) (Binder _ x) =
191193
do

0 commit comments

Comments
 (0)