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

render macro panics with index out of bounds error #1769

Closed
1 of 3 tasks
abhijeetbhagat opened this issue Dec 31, 2023 · 2 comments
Closed
1 of 3 tasks

render macro panics with index out of bounds error #1769

abhijeetbhagat opened this issue Dec 31, 2023 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@abhijeetbhagat
Copy link
Contributor

Problem

i am trying to do this:

...
div {
        class: "flex flex-col",
        for group in my_vec.iter().as_slice().group_by(|a, b| a.from_id == b.from_id) {

         }
}
...

with #![feature(slice_group_by)] add to the top in a mod.rs file and i get this:

message: index out of bounds: the len is 0 but the index is 0

removing the for loop doesn't cause panic.
the for loop works fine on the rust playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e8878294d72f9a525a8ed2cf2291ed28

Expected behavior

should not panic

Environment:

  • dioxus = "0.4.3"
  • dioxus-web = "0.4.3"
  • Rust version: 1.77 nightly
  • OS info: MacOS
  • App platform: web

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@ealmloff
Copy link
Member

The body of the for loop is rsx. You run into the same error if you try to use an empty rsx macro: rsx!{}

If you are interested in fixing this issue, I would start in the rsx macro. We are indexing into an empty array somewhere. Maybe here?

let spndbg = format!("{:?}", self.roots[0].span());

@ealmloff ealmloff added bug Something isn't working good first issue Good for newcomers labels Dec 31, 2023
@abhijeetbhagat
Copy link
Contributor Author

@ealmloff thanks for pointing out the source location. i shall look into this.

abhijeetbhagat added a commit to abhijeetbhagat/dioxus that referenced this issue Jan 1, 2024
ealmloff added a commit that referenced this issue Jan 2, 2024
* fix empty render causing panic (#1769)

* use an default root column instead of an empty root column

* fix formatting

* restore create.rs in core

---------

Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
@ealmloff ealmloff closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants