in src/main/java/org/apache/commons/jexl3/parser/JexlParser.java [271:313]
protected String checkVariable(final ASTIdentifier identifier, final String name) {
if (scope != null) {
final Integer symbol = scope.getSymbol(name);
if (symbol != null) {
identifier.setLexical(scope.isLexical(symbol));
boolean declared = true;
if (scope.isCapturedSymbol(symbol)) {
// captured are declared in all cases
identifier.setCaptured(true);
} else {
LexicalUnit unit = block;
declared = unit.hasSymbol(symbol);
// one of the lexical blocks above should declare it
if (!declared) {
for (final LexicalUnit u : blocks) {
if (u.hasSymbol(symbol)) {
unit = u;
declared = true;
break;
}
}
}
if (declared) {
// track if const is defined or not
if (unit.isConstant(symbol)) {
identifier.setConstant(true);
}
} else if (info instanceof JexlNode.Info) {
declared = isSymbolDeclared((JexlNode.Info) info, symbol);
}
}
identifier.setSymbol(symbol, name);
if (!declared) {
if (getFeatures().isLexicalShade()) {
// cannot reuse a local as a global
throw new JexlException.Parsing(info, name + ": variable is not declared").clean();
}
identifier.setShaded(true);
}
}
}
return name;
}