From cc014e659fdc9427e9e5d8875e835d307740d8da Mon Sep 17 00:00:00 2001 From: hallgren Date: Mon, 2 Mar 2015 14:27:36 +0000 Subject: [PATCH] Fix to avoid "error (no reason given) OCCURRED IN optimizing " GF.Compile.Optimize.mkLinReference can fail and cause this error because the helper function inside it applies msum to a list that might be empty (if there is a record type that does not contain a field of type Str). This means that it can return mzero::Err, i.e. Bad "error (no reason given)" which can slip through the top level test that only catches Bad "no string". --- src/compiler/GF/Compile/Optimize.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/GF/Compile/Optimize.hs b/src/compiler/GF/Compile/Optimize.hs index 28d0a7acb..4fec7e0b6 100644 --- a/src/compiler/GF/Compile/Optimize.hs +++ b/src/compiler/GF/Compile/Optimize.hs @@ -195,6 +195,7 @@ mkLinReference gr typ = RecType [] -> Bad "no string" RecType rs -> do msum (map (\(l,ty) -> mkDefField ty (P trm l)) (sortRec rs)) + `mplus` Bad "no string" _ | Just _ <- isTypeInts typ -> Bad "no string" _ -> Bad (render ("linearization type field cannot be" <+> typ))