summaryrefslogtreecommitdiff
path: root/src/compiler/GF
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2014-09-27 17:14:35 +0000
committeraarne <aarne@chalmers.se>2014-09-27 17:14:35 +0000
commitaef787aeb112f45547011f6fcc7e27b2aaddef96 (patch)
treec93544460685ecd011b5fb5becc3cde40809026c /src/compiler/GF
parentca1cad68d07b31c3b6f351205e3b75e75bd33b58 (diff)
checked that course of value tables (table P [...]) have the correct number of values w.r.t the type P. This was previously not checked, and caused hard-to-find run-time errors.
Diffstat (limited to 'src/compiler/GF')
-rw-r--r--src/compiler/GF/Compile/TypeCheck/Concrete.hs4
-rw-r--r--src/compiler/GF/Compile/TypeCheck/RConcrete.hs4
2 files changed, 8 insertions, 0 deletions
diff --git a/src/compiler/GF/Compile/TypeCheck/Concrete.hs b/src/compiler/GF/Compile/TypeCheck/Concrete.hs
index 89aaeb1fb..2afff7c6a 100644
--- a/src/compiler/GF/Compile/TypeCheck/Concrete.hs
+++ b/src/compiler/GF/Compile/TypeCheck/Concrete.hs
@@ -436,6 +436,10 @@ checkLType gr g trm typ0 = do
case typ of
Table arg1 val ->
do arg' <- checkEqLType gr g arg0 arg1 trm
+ vs1 <- allParamValues gr arg1
+ if length vs1 == length vs
+ then return ()
+ else checkError $ text "wrong number of values in table" <+> ppTerm Unqualified 0 trm
vs' <- map fst `fmap` sequence [checkLType gr g v val|v<-vs]
return (V arg' vs',typ)
diff --git a/src/compiler/GF/Compile/TypeCheck/RConcrete.hs b/src/compiler/GF/Compile/TypeCheck/RConcrete.hs
index ca8d789c1..67ff26115 100644
--- a/src/compiler/GF/Compile/TypeCheck/RConcrete.hs
+++ b/src/compiler/GF/Compile/TypeCheck/RConcrete.hs
@@ -468,6 +468,10 @@ checkLType gr g trm typ0 = do
case typ of
Table arg1 val ->
do arg' <- checkEqLType gr g arg0 arg1 trm
+ vs1 <- allParamValues gr arg1
+ if length vs1 == length vs
+ then return ()
+ else checkError $ "wrong number of values in table" <+> ppTerm Unqualified 0 trm
vs' <- map fst `fmap` sequence [checkLType gr g v val|v<-vs]
return (V arg' vs',typ)