From 2f6058d49f798de5f3597445e66ac1fdc13c4e89 Mon Sep 17 00:00:00 2001 From: arookas Date: Tue, 8 Mar 2016 02:16:13 -0500 Subject: [PATCH] Added error message for constant declarations. --- ssc/ast/nodes.variables.cs | 2 +- ssc/exceptions.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ssc/ast/nodes.variables.cs b/ssc/ast/nodes.variables.cs index 3c0596d..88043fd 100644 --- a/ssc/ast/nodes.variables.cs +++ b/ssc/ast/nodes.variables.cs @@ -35,7 +35,7 @@ var symbol = compiler.Context.DeclareVariable(this); symbol.Modifiers = Modifiers; if ((Modifiers & sunSymbolModifiers.Constant) != 0) { - throw new sunInvalidModifierException(this[0]); + throw new sunConstantDeclarationException(this); } } } diff --git a/ssc/exceptions.cs b/ssc/exceptions.cs index 26b004e..27298df 100644 --- a/ssc/exceptions.cs +++ b/ssc/exceptions.cs @@ -259,4 +259,12 @@ namespace arookas { public sunInvalidModifierException(sunNode node) : base(node) { } } + class sunConstantDeclarationException : sunNodeException { + public override string Message { + get { return "Constant variables must be assigned a value."; } + } + + public sunConstantDeclarationException(sunVariableDeclaration node) + : base(node) { } + } }