From 65af9d7f3c14df20c305f87e1551c71dcb53e9c6 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 20 Apr 2024 23:47:12 -0400 Subject: [PATCH] Perform constant evaluation during constant declaration analysis --- analyzer/type.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/analyzer/type.go b/analyzer/type.go index cc645b1..ebafd25 100644 --- a/analyzer/type.go +++ b/analyzer/type.go @@ -1,6 +1,7 @@ package analyzer import "fmt" +import "git.tebibyte.media/fspl/fspl/eval" import "git.tebibyte.media/fspl/fspl/errors" import "git.tebibyte.media/fspl/fspl/entity" @@ -101,11 +102,8 @@ func (this *Tree) analyzeConstantDeclaration ( value, err := this.analyzeExpression(into, strict, constant.Value) if err != nil { return nil, err } - // TODO once constant expression evaluation is implemented, do - // that here - - // only allow values that can be used as constants - err = this.isConstant(value) + // evaluate constant expression to literal value + value, err = eval.EvaluateConstant(value) if err != nil { return nil, err } }