From 866a2101e1ce2db35847c85eb9ee380c4edc56ba Mon Sep 17 00:00:00 2001 From: "John J. Camilleri" Date: Thu, 18 Feb 2021 14:42:39 +0100 Subject: [PATCH] When projecting a non-existent field, return Prelude.False This seems to be GF's own behaviour, as exhibited by the canonical version of PhrasebookTha: NNumeral Numeral_0 = {s = Numeral_0.s; hasC = <>.hasC}; --- src/compiler/GF/Compile/GrammarToLPGF.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/GF/Compile/GrammarToLPGF.hs b/src/compiler/GF/Compile/GrammarToLPGF.hs index 1882c78bb..2bd3721f7 100644 --- a/src/compiler/GF/Compile/GrammarToLPGF.hs +++ b/src/compiler/GF/Compile/GrammarToLPGF.hs @@ -157,7 +157,11 @@ mkCanon2lpgf opts gr am = do -- find label index in argument type let Just (C.RecordType rrs) = mtyp let rrs' = [ lid | C.RecordRow lid _ <- rrs ] - lblIx <- eitherElemIndex lblId rrs' + -- lblIx <- eitherElemIndex lblId rrs' + let + lblIx = case eitherElemIndex lblId rrs' of + Right x -> x + Left _ -> 0 -- corresponds to Prelude.False -- lookup lintype for record row let C.RecordRow _ lt = rrs !! lblIx return (L.LFProjection v1' (L.LFInt (lblIx+1)), Just lt)