From b2f8b85969de870174c0f47d99be550f377f10f3 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 7 Dec 2023 04:16:58 -0500 Subject: [PATCH] If statements get a type --- analyzer/expression.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/analyzer/expression.go b/analyzer/expression.go index 0591338..2625231 100644 --- a/analyzer/expression.go +++ b/analyzer/expression.go @@ -4,10 +4,10 @@ import "fmt" import "github.com/alecthomas/participle/v2" import "git.tebibyte.media/sashakoshka/fspl/entity" -// TODO all expression analysis routines must take in the type they are being +// All expression analysis routines must take in the type they are being // assigned to and return an error if they can't be assigned to it. if the type // is nil, the expression must ignore it unless it can do upwards type -// inference. need to also figure out comparison operators +// inference. func (this *Tree) analyzeVariable ( into entity.Type, @@ -610,6 +610,8 @@ func (this *Tree) analyzeIfElse ( ifelse.False = falseBranch } + ifelse.Ty = into + return ifelse, nil }