-
Notifications
You must be signed in to change notification settings - Fork 155
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
Wrong borrowing of expression in template! #262
Comments
I forgot to write an update on this issue. After I submitted the issue, I planned to write a MR but, while reading the I don't know if all instances of this should be wrapped in parenthesis. Look at this: > grep "(&__el|&#)" -ER packages/sycamore-macro/
packages/sycamore-macro/src/template/mod.rs: ::sycamore::template::IntoTemplate::create(&#splice)
packages/sycamore-macro/src/template/element.rs: ::sycamore::generic_node::GenericNode::append_child(&__el, &#element);
packages/sycamore-macro/src/template/element.rs: &__el,
packages/sycamore-macro/src/template/element.rs: &__el,
packages/sycamore-macro/src/template/element.rs: ::sycamore::template::IntoTemplate::create(&#splice),
packages/sycamore-macro/src/template/element.rs: ::sycamore::generic_node::GenericNode::append_child(&__el, &__marker);
packages/sycamore-macro/src/template/element.rs: ::sycamore::generic_node::GenericNode::append_child(&__el, &__marker);
packages/sycamore-macro/src/template/element.rs: ::sycamore::generic_node::GenericNode::append_child(&__el, &__marker);
packages/sycamore-macro/src/template/element.rs: &__el,
packages/sycamore-macro/src/template/element.rs: &__el,
packages/sycamore-macro/src/template/element.rs: ::sycamore::template::IntoTemplate::create(&#splice)
packages/sycamore-macro/src/template/attributes.rs: &::std::string::ToString::to_string(&#expr)
packages/sycamore-macro/src/template/attributes.rs: ::sycamore::generic_node::GenericNode::set_class_name(&__el, #quoted_text);
packages/sycamore-macro/src/template/attributes.rs: &__el,
packages/sycamore-macro/src/template/attributes.rs: let __el = ::std::clone::Clone::clone(&__el);
packages/sycamore-macro/src/template/attributes.rs: ::sycamore::generic_node::GenericNode::set_attribute(&__el, #name, "");
packages/sycamore-macro/src/template/attributes.rs: ::sycamore::generic_node::GenericNode::remove_attribute(&__el, #name);
packages/sycamore-macro/src/template/attributes.rs: let __el = ::std::clone::Clone::clone(&__el);
packages/sycamore-macro/src/template/attributes.rs: let __el = ::std::clone::Clone::clone(&__el);
packages/sycamore-macro/src/template/attributes.rs: &__el,
packages/sycamore-macro/src/template/attributes.rs: &__el,
packages/sycamore-macro/src/template/attributes.rs: &__el,
packages/sycamore-macro/src/template/attributes.rs: ::sycamore::rt::JsValue::as_bool(&#event_target_prop).unwrap()
packages/sycamore-macro/src/template/attributes.rs: ::sycamore::rt::JsValue::as_string(&#event_target_prop).unwrap()
packages/sycamore-macro/src/template/attributes.rs: let __el = ::std::clone::Clone::clone(&__el);
packages/sycamore-macro/src/template/attributes.rs: &__el,
packages/sycamore-macro/src/template/attributes.rs: &#convert_into_jsvalue_fn,
packages/sycamore-macro/src/template/attributes.rs: &__el,
packages/sycamore-macro/src/template/attributes.rs: &#expr,
packages/sycamore-macro/src/template/attributes.rs: ::std::clone::Clone::clone(&__el), I don't know if there are more of these. |
These don't need to be parenthesized because it references a variable. |
Describe the bug
Given an expression with multiple rvalues
a, b, c
, the macro will expand to&a....c
instead of&(a....c)
To Reproduce
Steps to reproduce the behavior:
The macro will expand
0+1
toIntoTemplate::create(&0+1)
instead ofIntoTemplate::create(&(0+1))
.Replacing
0+1
with(0+1)
so that the end result looks like((0+1))
makes it work.Expected behavior
Borrow the whole expression. Not only the first rvalue.
I think the macro should always wrap the expansion of the inner expression in parenthesis.
Environment
The text was updated successfully, but these errors were encountered: