Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treats an out of bounds access for an object sequence as truthy #11

Open
ajusa opened this issue Mar 6, 2023 · 1 comment
Open

Treats an out of bounds access for an object sequence as truthy #11

ajusa opened this issue Mar 6, 2023 · 1 comment

Comments

@ajusa
Copy link

ajusa commented Mar 6, 2023

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.

@beef331
Copy link

beef331 commented Mar 6, 2023

It presently does not work properly but a start of a solution resides: beef331@776618c

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants