@@ -85,13 +85,18 @@ compileDefinition target defn@Defn{..} = setCurrentRange defName do
8585 reportSDoc " agda2lambox.compile" 5 $
8686 " Found primitive: " <> prettyTCM defName
8787
88- getBuiltinThing (PrimitiveName primName) >>= \ case
89-
90- -- if it's a primitive with an actual implementation
91- -- we try to convert it to a function, manually
92- Just (Prim (PrimFun {})) -> do
88+ -- It's a primitive with no Agda definition
89+ if null primClauses then do
90+ -- we compile it as an axiom
91+ reportSDoc " agda2lambox.compile" 5 " Compiling it to an axiom."
92+ typ <- whenTyped target $ compileTopLevelType defType
93+ pure $ Just $ ConstantDecl $ ConstantBody typ Nothing
94+
95+ -- otherwise, we attempt compiling it as a regular Agda function
96+ else do
9397 reportSDoc " agda2lambox.compile" 5 $
9498 " It's a builtin, converting it to a function."
99+ reportSDoc " agda2lambox.compile" 5 $ prettyTCM primClauses
95100 let
96101 defn' = defn
97102 { theDef = Function
@@ -117,10 +122,5 @@ compileDefinition target defn@Defn{..} = setCurrentRange defName do
117122 -- and then we compile it as a regular function
118123 compileFunction target defn'
119124
120- -- otherwise, compiling it as an axiom
121- _ -> do
122- reportSDoc " agda2lambox.compile" 5 $ " Compiling it to an axiom."
123- typ <- whenTyped target $ compileTopLevelType defType
124- pure $ Just $ ConstantDecl $ ConstantBody typ Nothing
125125
126126 _ -> genericError $ " Cannot compile: " <> prettyShow defName
0 commit comments