stencilproject/Stencil

Index out of bounds should throw

Closed this issue · 1 comments

When a template contains an invalid index (e.g. elements.1 where elements only has 1 element) Stencil crashes with a fatal error.

In my opinion it would be better to throw if the index is out of bounds as the template is a user-written document and the assumption that a subscript index is correct doesn't hold.

I had a look through the code but couldn't figure out right away where this happens.
For variables I found one instance where the index wasn't checked, but not for context lookup for arrays:

current = array[index]

kylef commented

I agree @tkrajacic, fixed in 1e3afc0