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

Slicing vectors with negative indices returns wrong result #7096

Closed
AmesingFlank opened this issue Jan 9, 2023 · 2 comments · Fixed by #7212
Closed

Slicing vectors with negative indices returns wrong result #7096

AmesingFlank opened this issue Jan 9, 2023 · 2 comments · Fixed by #7212
Assignees
Labels
feature request Suggest an idea on this project

Comments

@AmesingFlank
Copy link
Collaborator

Consider this code segment

@ti.kernel
def k(i:int):
    x = ti.Vector([i, i+1, i+2])
    print(x[:-1])

k(0)

it prints out

[]
@jim19930609
Copy link
Contributor

I don't think we ever supported "-1" in either indexing or slicing. Shall I convert this issue to a feature request then?

@jim19930609 jim19930609 added the feature request Suggest an idea on this project label Jan 9, 2023
@AmesingFlank
Copy link
Collaborator Author

AmesingFlank commented Jan 9, 2023

I don't think we ever supported "-1" in either indexing or slicing. Shall I convert this issue to a feature request then?

That makes sense. The reason it felt more like a bug than a missing feature was that there was no warning messages. Notice that I didn't enable dynamic indexing, so the index is a compile-time constant and the compiler should be able to produce a warning about it being negative, yet it did not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Suggest an idea on this project
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants