Skip to content
Browse files
Add 'unexpected keyword/label' compile errors
Add "unexpected keyword" and "unexpected label" compile errors to static analysis. The caught cases are considered syntax errors and already caused a more generic 'fallback' compile error in static analysis.
  • Loading branch information
Pieter12345 committed Jul 18, 2020
1 parent 68e56fe commit 9c887c8d1d53836eb0de1d52db59d9e025b911e0
Showing 1 changed file with 9 additions and 0 deletions.
@@ -15,6 +15,8 @@
import com.laytonsmith.core.Static;
import com.laytonsmith.core.constructs.CClassType;
import com.laytonsmith.core.constructs.CFunction;
import com.laytonsmith.core.constructs.CKeyword;
import com.laytonsmith.core.constructs.CLabel;
import com.laytonsmith.core.constructs.CNull;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.CVoid;
@@ -390,6 +392,13 @@ public CClassType typecheck(ParseTree ast, Environment env, Set<ConfigCompileExc
} else if(node instanceof Variable) {
return CString.TYPE; // $vars can only be strings.
} else if(node instanceof CKeyword) {
exceptions.add(new ConfigCompileException("Unexpected keyword: " + node.val(), node.getTarget()));
return CClassType.AUTO;
} else if(node instanceof CLabel) {
exceptions.add(new ConfigCompileException(
"Unexpected label: " + ((CLabel) node).cVal().val(), node.getTarget()));
return CClassType.AUTO;

// The node is some other Construct, so return its type.

0 comments on commit 9c887c8

Please sign in to comment.