Fix nil index handling

This commit is contained in:
2024-02-11 22:11:17 -08:00
parent d9356a48a5
commit feb0f0db31
2 changed files with 18 additions and 1 deletions

View File

@@ -415,7 +415,7 @@ func (t *Template) getIndex(i ast.Index, local map[string]any) (any, error) {
return nil, ast.PosError(i, "%s: cannot get index of nil value", valueToString(i))
}
rindex := reflect.ValueOf(index)
if !rval.IsValid() {
if !rindex.IsValid() {
return nil, ast.PosError(i, "%s: cannot use nil value as an index", valueToString(i))
}