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

Unable to use more than one type argument #1894

Closed
1 of 3 tasks
ctron opened this issue Jun 1, 2021 · 9 comments
Closed
1 of 3 tasks

Unable to use more than one type argument #1894

ctron opened this issue Jun 1, 2021 · 9 comments
Labels
bug macro Issues relating to our procedural or declarative macros

Comments

@ctron
Copy link
Contributor

ctron commented Jun 1, 2021

Problem

Using more than one type argument in a component results in the follow error message during compilation:

error: expected a valid html element
  --> src/components/tabs.1.example:10:5
   |
10 |     </TabsRouter<crate::AppRoute, TabRoutes>>
   |     ^
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Steps To Reproduce

Create a component with more than one type argument.

Expected behavior

I would expect this to work, like with a single type argument.

Workaround

There is a workaround, you can define a type alias and use this instead:

type MyTabRouter = TabRouter<Foo,Bar>;

And then:

html![
  <MyTabRouter />
}

Environment:

  • Yew version: 0.17, 0.18
  • Rust version: 1.51

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
@ctron ctron added the bug label Jun 1, 2021
@siku2 siku2 added the macro Issues relating to our procedural or declarative macros label Jun 1, 2021
@lukechu10
Copy link
Contributor

lukechu10 commented Jun 1, 2021

Hmm, I thought I fixed this in #1738. There even is a trybuild test here:

fn compile_pass() {
html! { <Generic<String> /> };
html! { <Generic<String> ></Generic<String>> };
html! { <Generic<Vec<String>> /> };
html! { <Generic<Vec<String>>></ Generic<Vec<String>>> };
html! { <Generic<usize> /> };
html! { <Generic<usize>></Generic<usize>> };
html! { <Generic<String, > /> };
html! { <Generic<String, >></Generic<String,>> };
html! { <Generic2<String, String> /> };
html! { <Generic2<String, String>></Generic2<String, String>> };
html! { <Generic2<String, String, > /> };
html! { <Generic2<String, String, >></Generic2<String, String, >> };

Edit: Maybe it's because of the crate::AppRoute? If you add use crate::AppRoute and just use TabRouter<AppRouter, TabRoutes>, does it work?

@ctron
Copy link
Contributor Author

ctron commented Jun 2, 2021

Nope, I tried that at well. Didn't work.

@ctron
Copy link
Contributor Author

ctron commented Jun 2, 2021

Ah, it might be that I accidentally did not properly test with 0.18, only with 0.17. I will re-test that.

@ctron
Copy link
Contributor Author

ctron commented Jun 2, 2021

Ok, I am confused now. The code you have seems to be on "master", but not in "0.18". Although the changes older than the "0.18" release.

Anyway, I think it needs a bit more fixing :) It looks to me as if this only is a problem for the closing tag:

pub fn test() {
    // works
    let _foo = html! {
        <Foo<String,String>/>
    };
    // fails
    let _foo = html! {
        <Foo<String,String>>
        </Foo<String,String>>
    };
}

@ctron
Copy link
Contributor Author

ctron commented Jun 2, 2021

And, it fails with both 0.17 and 0.18.

@lukechu10
Copy link
Contributor

Ok, I am confused now. The code you have seems to be on "master", but not in "0.18". Although the changes older than the "0.18" release.

The commit probably didn't get cherry-picked onto the 0.18 release. Not sure why but you probably need to use a git dependency on master for now.

Also the second code snippet that fails should also work on master. It's identical to the trybuild test.

@ctron
Copy link
Contributor Author

ctron commented Jun 2, 2021

Ok, I am confused now. The code you have seems to be on "master", but not in "0.18". Although the changes older than the "0.18" release.

The commit probably didn't get cherry-picked onto the 0.18 release. Not sure why but you probably need to use a git dependency on master for now.

Ok, this is confusing. Especially as the version on master is still "0.17"!

Also the second code snippet that fails should also work on master. It's identical to the trybuild test.

I tried that with master, and indeed that works.

@ctron ctron closed this as completed Jun 2, 2021
@ctron
Copy link
Contributor Author

ctron commented Jun 2, 2021

@lukechu10 is there any date when the new release can be expected?

@lukechu10
Copy link
Contributor

Unfortunately I don't have any idea. I saw you on the discord server so maybe try asking there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug macro Issues relating to our procedural or declarative macros
Projects
None yet
Development

No branches or pull requests

3 participants