diff options
| author | hallgren <hallgren@chalmers.se> | 2013-11-12 13:55:38 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2013-11-12 13:55:38 +0000 |
| commit | 709b2bb067b4c3c2316e608e35bc59172f1452d9 (patch) | |
| tree | 0f48f90432a509ba99c10ffde3e550995d446e5e /src/compiler/GF | |
| parent | 31d7a9f73c10d5cd6eb6c96cb0cb05698a4bbd5a (diff) | |
Fix Issue 68: Cannot use an overloaded operator in table defined using square brackets
Add proper type checking of course-of-values tables:
+ Make sure that all subterms have the same type.
+ Resolve overloaded operators.
Note though that the GF book states in C.4.12 that the "course-of-values
table [...] format is not recommended for GF source code, since the
ordering of parameter values is not specified and therefore a
compiler-internal decision."
Diffstat (limited to 'src/compiler/GF')
| -rw-r--r-- | src/compiler/GF/Compile/TypeCheck/Concrete.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/compiler/GF/Compile/TypeCheck/Concrete.hs b/src/compiler/GF/Compile/TypeCheck/Concrete.hs index b58e9f5a2..67634d4f1 100644 --- a/src/compiler/GF/Compile/TypeCheck/Concrete.hs +++ b/src/compiler/GF/Compile/TypeCheck/Concrete.hs @@ -160,7 +160,8 @@ inferLType gr g trm = case trm of checkLType gr g trm (Table arg val) V arg pts -> do (_,val) <- checks $ map (inferLType gr g) pts - return (trm, Table arg val) +-- return (trm, Table arg val) -- old, caused issue 68 + checkLType gr g trm (Table arg val) K s -> do if elem ' ' s @@ -431,6 +432,12 @@ checkLType gr g trm typ0 = do cs' <- mapM (checkCase arg val) cs return (T (TTyped arg) cs', typ) _ -> checkError $ text "table type expected for table instead of" $$ nest 2 (ppType typ) + V arg0 vs -> + case typ of + Table arg1 val -> + do arg' <- checkEqLType gr g arg0 arg1 trm + vs' <- map fst `fmap` sequence [checkLType gr g v val|v<-vs] + return (V arg' vs',typ) R r -> case typ of --- why needed? because inference may be too difficult RecType rr -> do |
