slint
slint copied to clipboard
iterating with `for` does not compile within `Path`
Minimal example:
Waveform := Path {
height: 100px;
width: 100px;
MoveTo {
x: 0;
y: 0;
}
for sample[i] in [ 0, 1, 2, 3 ] : LineTo {
x: i;
y: sample;
}
Close {}
}
The error occurs accessing either the key (i
) or value (sample
). Replacing both the key and the value with numeric literals successfully compiles:
Waveform := Path {
height: 100px;
width: 100px;
MoveTo {
x: 0;
y: 0;
}
for sample[i] in [ 0, 1, 2, 3 ] : LineTo {
x: 10;
y: 10;
}
Close {}
}
The compiler panics on this line at unwrap
:
moire on main [$!?] is 📦 v0.1.0 via 🦀 v1.57.0
❯ RUST_BACKTRACE=full mold -run cargo run -- ~/music/Emancipator\ -\ 2006\ -\ Soon\ It\ Will\ Be\ Cold\ Enough/02\ Emancipator\ -\ Soon\ It\ Will\ Be\ Cold\ Enough\ To\ Build\ Fires.flac
Compiling moire v0.1.0 (/home/be/sw/moire)
error: failed to run custom build command for `moire v0.1.0 (/home/be/sw/moire)`
Caused by:
process didn't exit successfully: `/home/be/sw/moire/target/debug/build/moire-add10bb873b8dc2f/build-script-build` (exit status: 101)
--- stderr
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1572:69
stack backtrace:
0: 0x5561b81425fc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3264ad1edb4a78ca
1: 0x5561b816536c - core::fmt::write::h85b247e856e081ad
2: 0x5561b813e435 - std::io::Write::write_fmt::he3b80a66fc2ba5d3
3: 0x5561b81441d0 - std::panicking::default_hook::{{closure}}::hf2bcdea8e51c0c13
4: 0x5561b8143d85 - std::panicking::default_hook::h8864cfaaed08e53a
5: 0x5561b81449f4 - std::panicking::rust_panic_with_hook::hb272975096b9f3ce
6: 0x5561b8144472 - std::panicking::begin_panic_handler::{{closure}}::hbbd6c4e11858ba52
7: 0x5561b8142ac4 - std::sys_common::backtrace::__rust_end_short_backtrace::hdd56e8729123abc5
8: 0x5561b8144409 - rust_begin_unwind
9: 0x5561b8163471 - core::panicking::panic_fmt::h9596d5ee0dabf3a3
10: 0x5561b816335d - core::panicking::panic::h4a8207b1d3e5c6bf
11: 0x5561b74edc2c - core::option::Option<T>::unwrap::h01bb9e7ef7872850
at /builddir/build/BUILD/rustc-1.57.0-src/library/core/src/option.rs:746:21
12: 0x5561b77daafe - sixtyfps_compilerlib::object_tree::visit_all_named_references_in_element::recurse_expression::h7f472d0feae5bbe3
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1572:51
13: 0x5561b77dbce5 - sixtyfps_compilerlib::object_tree::visit_all_named_references_in_element::recurse_expression::{{closure}}::h254e6a95819f9ce0
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1561:30
14: 0x5561b750b27d - sixtyfps_compilerlib::expression_tree::Expression::visit_mut::h18f0848f4fa1413b
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/expression_tree.rs:703:46
15: 0x5561b77da9de - sixtyfps_compilerlib::object_tree::visit_all_named_references_in_element::recurse_expression::h7f472d0feae5bbe3
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1561:9
16: 0x5561b77dbce5 - sixtyfps_compilerlib::object_tree::visit_all_named_references_in_element::recurse_expression::{{closure}}::h254e6a95819f9ce0
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1561:30
17: 0x5561b7516527 - sixtyfps_compilerlib::expression_tree::Expression::visit_mut::{{closure}}::hcb92588f9e92c9be
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/expression_tree.rs:742:49
18: 0x5561b747e17d - core::iter::traits::iterator::Iterator::for_each::call::{{closure}}::h8f9c3b598fff2121
at /builddir/build/BUILD/rustc-1.57.0-src/library/core/src/iter/traits/iterator.rs:734:29
19: 0x5561b76221fe - core::iter::traits::iterator::Iterator::fold::h5cafbae4a53a0fc0
at /builddir/build/BUILD/rustc-1.57.0-src/library/core/src/iter/traits/iterator.rs:2171:21
20: 0x5561b7626082 - core::iter::traits::iterator::Iterator::for_each::hdc27c869a9ced8e9
at /builddir/build/BUILD/rustc-1.57.0-src/library/core/src/iter/traits/iterator.rs:737:9
21: 0x5561b750b7d5 - sixtyfps_compilerlib::expression_tree::Expression::visit_mut::h18f0848f4fa1413b
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/expression_tree.rs:739:25
22: 0x5561b77da9de - sixtyfps_compilerlib::object_tree::visit_all_named_references_in_element::recurse_expression::h7f472d0feae5bbe3
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1561:9
23: 0x5561b77d8ef6 - sixtyfps_compilerlib::object_tree::visit_all_named_references_in_element::{{closure}}::ha57d425f43033ff7
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1580:50
24: 0x5561b77c4e38 - sixtyfps_compilerlib::object_tree::visit_element_expressions::visit_element_expressions_simple::h301c5f6297e84852
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1508:13
25: 0x5561b77b2d43 - sixtyfps_compilerlib::object_tree::visit_element_expressions::h5e901d8c6a812f66
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1531:5
26: 0x5561b77d2810 - sixtyfps_compilerlib::object_tree::visit_all_named_references_in_element::h7048564a9c51f03b
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1580:5
27: 0x5561b77dc473 - sixtyfps_compilerlib::object_tree::visit_all_named_references::{{closure}}::h7ae2289479ef1e4d
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1633:13
28: 0x5561b77ac06b - sixtyfps_compilerlib::object_tree::recurse_elem_including_sub_components_no_borrow::{{closure}}::ha8e4d5ddba36da74
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1479:9
29: 0x5561b77a5bbf - sixtyfps_compilerlib::object_tree::recurse_elem_no_borrow::h6092032b7c54c5b0
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1453:17
30: 0x5561b77a5da3 - sixtyfps_compilerlib::object_tree::recurse_elem_no_borrow::h6092032b7c54c5b0
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1456:9
31: 0x5561b77a8f3c - sixtyfps_compilerlib::object_tree::recurse_elem_including_sub_components_no_borrow::hdac59dd625e61c42
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1466:5
32: 0x5561b77dbeee - sixtyfps_compilerlib::object_tree::visit_all_named_references::h3e4b751a5ad22d86
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/object_tree.rs:1629:5
33: 0x5561b7687c47 - sixtyfps_compilerlib::passes::repeater_component::adjust_references::hbdf5968c061fadbe
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/passes/repeater_component.rs:96:5
34: 0x5561b7685d4d - sixtyfps_compilerlib::passes::repeater_component::process_repeater_components::h806697f41e83c5fe
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/passes/repeater_component.rs:22:5
35: 0x5561b73c7e45 - sixtyfps_compilerlib::passes::run_passes::{{closure}}::h840b8fb152303560
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/passes.rs:104:9
36: 0x5561b73e67b9 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hfc99a7583e76a8e4
at /builddir/build/BUILD/rustc-1.57.0-src/library/core/src/future/mod.rs:80:19
37: 0x5561b73c5a1b - sixtyfps_compilerlib::compile_syntax_node::{{closure}}::hd5ae58139795e18b
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/sixtyfps_compiler/lib.rs:147:9
38: 0x5561b73e6645 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::ha528d369ba37aa2d
at /builddir/build/BUILD/rustc-1.57.0-src/library/core/src/future/mod.rs:80:19
39: 0x5561b73b014e - spin_on::spin_on::ha01bcaffabdce3b7
at /home/be/.cargo/registry/src/github.com-1ecc6299db9ec823/spin_on-0.1.1/src/lib.rs:78:38
40: 0x5561b73bc177 - sixtyfps_build::compile_with_config::h5c5e0913019f2498
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/api/sixtyfps-rs/sixtyfps-build/lib.rs:222:27
41: 0x5561b73bddb0 - sixtyfps_build::compile::hee3d8dfc943afc6f
at /home/be/.cargo/git/checkouts/sixtyfps-1a243e0ff9772996/75136e1/api/sixtyfps-rs/sixtyfps-build/lib.rs:177:5
42: 0x5561b73ad2da - build_script_build::main::hc659a1661f67fc7d
at /home/be/sw/moire/build.rs:2:5
43: 0x5561b73ae43b - core::ops::function::FnOnce::call_once::hf639b1f56c2392b5
at /builddir/build/BUILD/rustc-1.57.0-src/library/core/src/ops/function.rs:227:5
44: 0x5561b73d93fe - std::sys_common::backtrace::__rust_begin_short_backtrace::heee0fa855293041f
at /builddir/build/BUILD/rustc-1.57.0-src/library/std/src/sys_common/backtrace.rs:123:18
45: 0x5561b73c5e41 - std::rt::lang_start::{{closure}}::h10564da0565086e0
at /builddir/build/BUILD/rustc-1.57.0-src/library/std/src/rt.rs:146:18
46: 0x5561b81422db - std::rt::lang_start_internal::hcbc5d1079a591413
47: 0x5561b73c5e10 - std::rt::lang_start::h07aea8c407067c66
at /builddir/build/BUILD/rustc-1.57.0-src/library/std/src/rt.rs:145:17
48: 0x5561b73ad30c - main
49: 0x7fbf0e453560 - __libc_start_call_main
50: 0x7fbf0e45360c - __libc_start_main@@GLIBC_2.34
51: 0x5561b73ad095 - _start
52: 0x0 - <unknown>
Ouch, there are two bugs at hand here. (1) the compiler should not panic but produce an error message that this isn't supported at the moment and (2) we should support this in the future probably :-)
i have an probably related error. i am on latest master ec26714cc0316983fcad25bbca7b29263742240c it is compiling and i got no error message in 60 compiler. code looks like this:
export struct my_curve := {
line: bool,
arc:bool,
cubic: bool,
quadratic: bool,
from_x: float,
....
control-2-y: float,
....
}
property<[my_curve]> array_of_paths : [{ line: true,
arc: false,
cubic: false,
quadratic: false,
from_x: 0,
....
}];
than i try to construct it like this:
for mycurve[i] in array_of_paths:
Path {
stroke: red;
stroke-width: 2px;
MoveTo{
x: mycurve.from_x;
y: mycurve.from_y;
}
if mycurve.line : LineTo {
x: mycurve.to_x;
y: mycurve.to_y;
}
if mycurve.arc : ArcTo {
x: mycurve.to_x;
y: mycurve.to_y;
radius-x: mycurve.control-1-x;
.....
sweep: mycurve.sweep;
}
.....
}
it will always create all sub-path elements -> the if statement is not working. I tryed also directly using propertys for the if statement and used different syntax like if mycurve.arc == true :
always no error but also not working
I can reproduce the panic
Any chance that we are going to be able to use "if" and "for" inside a Path in the next release?
This would be very handy for simple dynamic graphs.