elvis
elvis copied to clipboard
Treats an out of bounds access for an object sequence as truthy
Not quite sure what is going on, but I do have a minimal reproducible example:
import elvis
var a: seq[int] = @[]
echo ?(a[0])
type Story* = object
var stories: seq[Story]
echo ?(stories[0])
This prints
false
true
which is pretty counter intuitive, as I'd expect the second echo to print false as well.
It presently does not work properly but a start of a solution resides: https://github.com/beef331/elvis/commit/776618c14a7d0f89e7d06ee103519295645ec9b6
Basically what one needs to do is to break apart the untyped expression unto a chain of truthy(let arg = expr; arg) and truthy(let arg2 = expr(arg1); arg2) ....) this does that and compiles for some amount of these, but due to untyped AST requirement it needs to be smarter.