Skip to content

for within a GridLayout produces invalid code, or panics #349

@koutoftimer

Description

@koutoftimer

Steps to reproduce:

#!/bin/sh
cargo new bug 
cd bug
echo 'sixtyfps = "0.1.0"' >> Cargo.toml
cat > src/main.rs <<- EOM
fn main() {
    MainWindow::new().run();
}

sixtyfps::sixtyfps! {
    MainWindow := Window {
        //Image {
        //    source: @image-url("icons/bus.png");
        //}
        GridLayout {
            for img in [
                @image-url("icons/bus.png"),
                @image-url("icons/bus.png"),
                @image-url("icons/bus.png"),
                @image-url("icons/bus.png"),
                @image-url("icons/bus.png")
            ] : Image {
                source: img;
            }
        }
    }
}
EOM
cargo run --release

# to ensure that creating single image will work, can be omitted
curl -O https://sixtyfps.io/blog/memory-game-tutorial/icons.zip && unzip icons.zip

gives an error:

error[E0609]: no field `image_3` on type `InnerMainWindowFieldsOffsets`
  --> src/main.rs:5:1
   |
5  | / sixtyfps::sixtyfps! {
6  | |     MainWindow := Window {
7  | |         //Image {
8  | |         //    source: @image-url("icons/bus.png");
...  |
21 | |     }
22 | | }
   | |_^ unknown field
   |
   = note: available fields are: `root_1`, `gridlayout_2`, `gridlayout_2_layout_cache_h`, `gridlayout_2_layout_cache_v`, `gridlayout_2_layoutinfo_h` ... and 7 others
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:compilerSlint compiler internal (not the codegen, not the parser)a:layoutsRelated to the layouting and positioning of the elements (mO,bT)good first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions