Perform constant evaluation during constant declaration analysis

This commit is contained in:
Sasha Koshka 2024-04-20 23:47:12 -04:00
parent b5f5fa4598
commit 65af9d7f3c
1 changed files with 3 additions and 5 deletions

View File

@ -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 }
}