Fix bugs relating to . and this.

First, I missed some reference checks when I stopped interning names. Fixed
those.

Second, when iterating over an array which contained null elements, the wrong
thing was happening.
This commit is contained in:
Michael Bayne
2018-06-04 16:06:50 -07:00
parent b823ed87c5
commit 4533567303
4 changed files with 21 additions and 16 deletions
@@ -856,8 +856,10 @@ public class Mustache {
@Override public void execute (Template tmpl, Template.Context ctx, Writer out) {
Object value = tmpl.getValueOrDefault(ctx, _name, _line);
if (value == null) {
throw new MustacheException.Context("No key, method or field with name '" + _name +
"' on line " + _line, _name, _line);
String msg = Template.isThisName(_name) ?
"Resolved '.' to null (which is disallowed), on line " + _line :
"No key, method or field with name '" + _name + "' on line " + _line;
throw new MustacheException.Context(msg, _name, _line);
}
write(out, _escaper.escape(_formatter.format(value)));
}