diff --git a/examples/shadow-tests.dx b/examples/shadow-tests.dx index 6125a7fcf..08c57eafd 100644 --- a/examples/shadow-tests.dx +++ b/examples/shadow-tests.dx @@ -1,10 +1,10 @@ -- repeated vars in patterns not allowed :p (x, x) = (1, 1); x -> Variable redefined: x +> Error: variable already defined: x :p f (x, x) = x; f (1, 1) -> Variable redefined: x +> Error: variable already defined: x -- TODO: re-enable if we choose to allow non-peer shadowing -- -- shouldn't cause error even though it shadows x elsewhere @@ -21,7 +21,7 @@ arr = 10 -- _ = 10 -- underscore shadows allowed arr = 20 -> Variable redefined: arr +> Error: variable already defined: arr :p arr > 10 diff --git a/examples/type-tests.dx b/examples/type-tests.dx index aefc6eed9..6ece8944f 100644 --- a/examples/type-tests.dx +++ b/examples/type-tests.dx @@ -160,4 +160,4 @@ f x = > ^^ :t x = 3 for i::x. 0 -> Variable not in scope:type variable "x" (a term variable of the same name is in scope) +> Error: variable not in scope: type variable "x" (a term variable of the same name is in scope) diff --git a/src/lib/DeShadow.hs b/src/lib/DeShadow.hs index 5981731e7..c04cdf80c 100644 --- a/src/lib/DeShadow.hs +++ b/src/lib/DeShadow.hs @@ -119,7 +119,7 @@ freshBinderP :: BinderP a -> DeShadowCat (BinderP a) freshBinderP (v:>ann) = do shadowed <- looks $ (v `isin`) . fst . fst if shadowed && v /= Name "_" 0 - then throw RepeatedVarErr (" " ++ pprint v) + then throw RepeatedVarErr (pprint v) else return () v' <- looks $ rename v . snd extend (asFst (v@>v'), v'@>()) @@ -129,7 +129,7 @@ freshTBinder :: TBinder -> DeShadowCat TBinder freshTBinder (v:>k) = do shadowed <- looks $ (v `isin`) . snd . fst if shadowed && v /= Name "_" 0 - then throw RepeatedVarErr (" " ++ pprint v) + then throw RepeatedVarErr (pprint v) else return () v' <- looks $ rename v . snd extend (asSnd (v@>TypeVar v'), v'@>()) diff --git a/src/lib/JIT.hs b/src/lib/JIT.hs index 3aa7bc400..b875542a4 100644 --- a/src/lib/JIT.hs +++ b/src/lib/JIT.hs @@ -417,7 +417,7 @@ compileBuiltin b ts = case b of FDiv -> compileBinop RealType (\x y -> L.FDiv noFastMathFlags x y []) FLT -> compileBinop BoolType (\x y -> L.FCmp L.OLT x y []) FGT -> compileBinop BoolType (\x y -> L.FCmp L.OGT x y []) - Todo -> const $ throw OtherErr "Can't compile 'todo'" + Todo -> const $ throw MiscErr "Can't compile 'todo'" BoolToInt -> compileUnop IntType (\x -> L.ZExt x longTy []) IntToReal -> compileUnop RealType (\x -> L.SIToFP x realTy []) FFICall _ name -> compileFFICall name ts diff --git a/src/lib/PPrint.hs b/src/lib/PPrint.hs index e74494d89..fd2d332b1 100644 --- a/src/lib/PPrint.hs +++ b/src/lib/PPrint.hs @@ -43,12 +43,11 @@ instance Pretty ErrType where ParseErr -> "Parse error:" TypeErr -> "Type error:" LinErr -> "Linearity error:" - CompilerErr -> "Compiler bug!" - UnboundVarErr -> "Variable not in scope:" - RepeatedVarErr -> "Variable redefined:" + UnboundVarErr -> "Error: variable not in scope: " + RepeatedVarErr -> "Error: variable already defined: " NotImplementedErr -> "Not implemented:" - OtherErr -> "Error:" - UpstreamErr -> "Upstream failure" + CompilerErr -> "Compiler bug!" + MiscErr -> "Error:" instance Pretty Type where pretty t = prettyTyDepth 0 t diff --git a/src/lib/Syntax.hs b/src/lib/Syntax.hs index bb9a5581a..29128ce52 100644 --- a/src/lib/Syntax.hs +++ b/src/lib/Syntax.hs @@ -301,8 +301,7 @@ data ErrType = NoErr | RepeatedVarErr | CompilerErr | NotImplementedErr - | UpstreamErr - | OtherErr + | MiscErr deriving (Show) type Except a = Either Err a