From cddf8c6fa5049d2dd862217cb62b3ceaa404f5a5 Mon Sep 17 00:00:00 2001 From: Niklas Larsson Date: Thu, 9 Jul 2020 22:45:37 +0200 Subject: [PATCH] Fix bootstrap Replace if-expression with a function --- .github/workflows/ci-full-bootstrap.yml | 2 +- src/Compiler/ES/Imperative.idr | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-full-bootstrap.yml b/.github/workflows/ci-full-bootstrap.yml index e523651e3..575b72092 100644 --- a/.github/workflows/ci-full-bootstrap.yml +++ b/.github/workflows/ci-full-bootstrap.yml @@ -2,7 +2,7 @@ name: Idris bootstrap on: push: branches: - - master + - '*' tags: - '*' diff --git a/src/Compiler/ES/Imperative.idr b/src/Compiler/ES/Imperative.idr index 39fc993b2..53939fb88 100644 --- a/src/Compiler/ES/Imperative.idr +++ b/src/Compiler/ES/Imperative.idr @@ -54,14 +54,17 @@ genName = pure $ MN "imp_gen" i mutual + ifThenElse : Bool -> a -> a -> a + ifThenElse True t e = t + ifThenElse False t e = e pairToReturn : (toReturn : Bool) -> (ImperativeStatement, ImperativeExp) -> - Core (if toReturn then ImperativeStatement else (ImperativeStatement, ImperativeExp)) + Core (ifThenElse toReturn ImperativeStatement (ImperativeStatement, ImperativeExp)) pairToReturn False (s, e) = pure (s, e) pairToReturn True (s, e) = pure $ s <+> ReturnStatement e expToReturn : (toReturn : Bool) -> ImperativeExp -> - Core (if toReturn then ImperativeStatement else (ImperativeStatement, ImperativeExp)) + Core (ifThenElse toReturn ImperativeStatement (ImperativeStatement, ImperativeExp)) expToReturn False e = pure $ (DoNothing, e) expToReturn True e = pure $ ReturnStatement e @@ -78,7 +81,7 @@ mutual pure (concat (map fst a), map snd a) impExp : {auto c : Ref Imps ImpSt} -> (toReturn : Bool) -> NamedCExp -> - Core (if toReturn then ImperativeStatement else (ImperativeStatement, ImperativeExp)) + Core (ifThenElse toReturn ImperativeStatement (ImperativeStatement, ImperativeExp)) impExp toReturn (NmLocal fc n) = expToReturn toReturn $ IEVar n impExp toReturn (NmRef fc n) = expToReturn toReturn $ IEVar n impExp toReturn (NmLam fc n e) = expToReturn toReturn $ IELambda [n] !(impExp True e)