mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
Nonlinear patterns in concrete syntax are now detected and reported as errors
Before, they were silently converted to linear patterns. Nonlinear patterns in MorphoCat.gf, ParadigmsGre.gf and ParadigmsFin.gf have been make linear by renaming pattern variables.
This commit is contained in:
@@ -39,7 +39,7 @@ import GF.Grammar.Printer
|
||||
import GF.Data.Operations
|
||||
|
||||
import Control.Monad
|
||||
import Data.List (nub)
|
||||
import Data.List (nub,(\\))
|
||||
import Text.PrettyPrint
|
||||
|
||||
-- | this gives top-level access to renaming term input in the cc command
|
||||
@@ -235,8 +235,14 @@ renameTerm env vars = ren vars where
|
||||
|
||||
-- | vars not needed in env, since patterns always overshadow old vars
|
||||
renamePattern :: Status -> Patt -> Check (Patt,[Ident])
|
||||
renamePattern env patt = case patt of
|
||||
|
||||
renamePattern env patt =
|
||||
do r@(p',vs) <- renp patt
|
||||
let dupl = vs \\ nub vs
|
||||
unless (null dupl) $ checkError (hang (text "[C.4.13] Pattern is not linear:") 4
|
||||
(ppPatt Unqualified 0 patt))
|
||||
return r
|
||||
where
|
||||
renp patt = case patt of
|
||||
PMacro c -> do
|
||||
c' <- renid $ Vr c
|
||||
case c' of
|
||||
@@ -301,8 +307,6 @@ renamePattern env patt = case patt of
|
||||
|
||||
_ -> return (patt,[])
|
||||
|
||||
where
|
||||
renp = renamePattern env
|
||||
renid = renameIdentTerm env
|
||||
renid' = renameIdentTerm' env
|
||||
|
||||
|
||||
Reference in New Issue
Block a user