fix(variable): Prevent crash on unknown index in array

This commit is contained in:
Kyle Fuller
2016-10-13 13:11:02 +01:00
parent 72f3cb579a
commit 1e3afc0dd5
3 changed files with 29 additions and 1 deletions

View File

@@ -64,7 +64,11 @@ public struct Variable : Equatable, Resolvable {
current = dictionary[bit]
} else if let array = current as? [Any] {
if let index = Int(bit) {
current = array[index]
if index >= 0 && index < array.count {
current = array[index]
} else {
current = nil
}
} else if bit == "first" {
current = array.first
} else if bit == "last" {