diff --git a/ssc/ast/nodes.variables.cs b/ssc/ast/nodes.variables.cs index 2610150..30d39a8 100644 --- a/ssc/ast/nodes.variables.cs +++ b/ssc/ast/nodes.variables.cs @@ -74,6 +74,13 @@ : base(location) { } public override void Compile(sunContext context) { + // analyze the expression first. this does two things: + // 1) prevents recursion (i.e. the const referencing itself) + // 2) asserts actual constness + var flags = Expression.Analyze(context); + if (flags.HasFlag(sunExpressionFlags.Dynamic)) { + throw new sunConstantExpressionException(Expression); + } context.DeclareConstant(Constant, Expression); } }