From 2139e7832c1c80c455bac77e40ca96521d5af9b3 Mon Sep 17 00:00:00 2001 From: MisterChaos96 Date: Thu, 13 Jun 2024 17:33:30 +0200 Subject: [PATCH] fix missing Typed Expression for local and field variable --- src/Typecheck.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Typecheck.hs b/src/Typecheck.hs index 8374ea4..5e5efc5 100644 --- a/src/Typecheck.hs +++ b/src/Typecheck.hs @@ -48,8 +48,9 @@ typeCheckExpression (Reference id) symtab classes = in case classDetails of Just (Class _ _ fields) -> let fieldTypes = [dt | VariableDeclaration dt fieldId _ <- fields, fieldId == id] + -- this case only happens when its a field of its own class so the implicit this will be converted to explicit this in case fieldTypes of - [fieldType] -> TypedExpression fieldType (BinaryOperation NameResolution (LocalVariable "this") (FieldVariable id)) + [fieldType] -> TypedExpression fieldType (BinaryOperation NameResolution (TypedExpression className (LocalVariable "this")) (TypedExpression fieldType (FieldVariable id))) [] -> error $ "Field '" ++ id ++ "' not found in class '" ++ className ++ "'" _ -> error $ "Ambiguous reference to field '" ++ id ++ "' in class '" ++ className ++ "'" Nothing -> error $ "Class '" ++ className ++ "' not found for 'this'"