Out of range exception in Expression.description
joshdistler opened this issue · 0 comments
When a function string is partially complete, such as "pow" (instead of "pow(2,4)") the Expression.description function will hit an exception at return "\(params[0]) \(token) \(params[1])"
, most likely because there is no parameter in param[1] yet. This could obviously be avoided by not getting the description without first validating for errors (but probably shouldn't be required). Adding count checking, more of a diagnostic than a fix, does avoid the error until the string is complete.
This should elicit the exception.
let tokenizer = Tokenizer(string: "pow")
let resolver = TokenResolver(tokenizer: tokenizer, options: .default)
let grouper = TokenGrouper(resolver: resolver)
let expressionizer = Expressionizer(grouper: grouper)
let description = expressionizer.expression().description