From 52184258f8eef227c743726770e984202e101919 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 2 Mar 2025 12:57:07 +0100 Subject: Compile: index into arrays --- src/Language/AST.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Language/AST.hs') diff --git a/src/Language/AST.hs b/src/Language/AST.hs index 022e797..387915b 100644 --- a/src/Language/AST.hs +++ b/src/Language/AST.hs @@ -17,7 +17,7 @@ module Language.AST where import Data.Kind (Type) import Data.Type.Equality import GHC.OverloadedLabels -import GHC.TypeLits (Symbol, SSymbol, symbolSing, KnownSymbol, TypeError, ErrorMessage(Text)) +import GHC.TypeLits (Symbol, SSymbol, symbolSing, KnownSymbol, TypeError, ErrorMessage(..)) import Array import AST @@ -77,6 +77,7 @@ deriving instance Show (NExpr env t) type family Lookup name env where Lookup "_" _ = TypeError (Text "Attempt to use variable with name '_'") + Lookup name '[] = TypeError (Text "Variable '" :<>: Text name :<>: Text "' not in scope") Lookup name ('(name, t) : env) = t Lookup name (_ : env) = Lookup name env -- cgit v1.2.3-70-g09d2