From d7916c1b085826fc6be73527dde70db00941e909 Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 5 Sep 2013 15:20:41 +0000 Subject: [PATCH] Fix an old bug that prevented pattern matching agains values containg tables The function GF.Grammar.PatternMatch.isInConstantForm returned False for all tables, causing matchPattern to fail, claiming that "variables occur in" the term if it contains tables. This problem is several years old, confirmed present in GF 3.2.10 (Oct 2010). --- src/compiler/GF/Grammar/PatternMatch.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/GF/Grammar/PatternMatch.hs b/src/compiler/GF/Grammar/PatternMatch.hs index e1b5f904f..bd92e3096 100644 --- a/src/compiler/GF/Grammar/PatternMatch.hs +++ b/src/compiler/GF/Grammar/PatternMatch.hs @@ -77,6 +77,7 @@ tryMatch (p,t) = do isInConstantFormt = True -- tested already in matchPattern trym p t' = case (p,t') of +-- (_,(x,Typed e ty,y)) -> trym p (x,e,y) -- Add this? /TH 2013-09-05 (_,(x,Empty,y)) -> trym p (x,K [],y) -- because "" = [""] = [] (PW, _) | isInConstantFormt -> return [] -- optimization with wildcard (PV x, _) | isInConstantFormt -> return [(x,t)] @@ -187,6 +188,9 @@ isInConstantForm trm = case trm of K _ -> True Empty -> True EInt _ -> True + V ty ts -> isInConstantForm ty && all isInConstantForm ts -- TH 2013-09-05 +-- Typed e t-> isInConstantForm e && isInConstantForm t -- Add this? TH 2013-09-05 + _ -> False ---- isInArgVarForm trm {- -- unused and suspicuous, see contP in GF.Compile.Compute.Concrete instead varsOfPatt :: Patt -> [Ident]