diff options
author | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2013-10-05 17:21:44 +0200 |
---|---|---|
committer | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2013-10-12 18:51:15 +0200 |
commit | 2216b4d37fa12f7e9d16d8942d3ec9d0ad5376e6 (patch) | |
tree | 15d84471383d8eff44a46428a463957a573b4b0d /compiler/rename | |
parent | 77d2aa5fd4ab6e20f84f3725e7ae6a65fb18d5a1 (diff) | |
download | haskell-2216b4d37fa12f7e9d16d8942d3ec9d0ad5376e6.tar.gz |
Reject negative type-level integers created via TH (#8412)
This commit moves the check from parser to renamer.
Diffstat (limited to 'compiler/rename')
-rw-r--r-- | compiler/rename/RnTypes.lhs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rename/RnTypes.lhs b/compiler/rename/RnTypes.lhs index 9aeae7e20c..0db92e8f90 100644 --- a/compiler/rename/RnTypes.lhs +++ b/compiler/rename/RnTypes.lhs @@ -223,12 +223,17 @@ rnHsTyKi isType doc tupleTy@(HsTupleTy tup_con tys) ; (tys', fvs) <- mapFvRn (rnLHsTyKi isType doc) tys ; return (HsTupleTy tup_con tys', fvs) } --- 1. Perhaps we should use a separate extension here? --- 2. Check that the integer is positive? +-- Perhaps we should use a separate extension here? +-- Ensure that a type-level integer is nonnegative (#8306, #8412) rnHsTyKi isType _ tyLit@(HsTyLit t) = do { data_kinds <- xoptM Opt_DataKinds ; unless (data_kinds || isType) (addErr (dataKindsErr isType tyLit)) + ; when (negLit t) (addErr negLitErr) ; return (HsTyLit t, emptyFVs) } + where + negLit (HsStrTy _) = False + negLit (HsNumTy i) = i < 0 + negLitErr = ptext (sLit "Illegal literal in type (type literals must not be negative):") <+> ppr tyLit rnHsTyKi isType doc (HsAppTy ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi isType doc ty1 |