Skip to content

rsx assumes get_line_num to be in scope #478

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

Closed
1 task done
rMazeiks opened this issue Jul 1, 2022 · 3 comments
Closed
1 task done

rsx assumes get_line_num to be in scope #478

rMazeiks opened this issue Jul 1, 2022 · 3 comments
Labels
core relating to the core implementation of the virtualdom

Comments

@rMazeiks
Copy link
Contributor

rMazeiks commented Jul 1, 2022

This doesn't compile:

use dioxus::prelude::rsx;

fn main() {
    rsx!(div {});
}

Error:

error: cannot find macro `get_line_num` in this scope
 --> docs/guide/examples/test.rs:4:5
  |
4 |     rsx!(div {});
  |     ^^^^^^^^^^^^
  |
  = note: consider importing this macro:
          dioxus::prelude::get_line_num
  = note: this error originates in the macro `rsx` (in Nightly builds, run with -Z macro-backtrace for more info)

Importing the full prelude fixes it. Still, would be nice for the macro to be accessed through the absolute path for rsx to be clean.

  • I'm doing something else right now, but maybe I'll fix this later
@ealmloff
Copy link
Member

ealmloff commented Jul 1, 2022

We could use absolute paths for most of the macro, and with rsx-prelude it should still work in tests. I think @jkelleyrtp had some thoughts on this? dioxus_elements also needs to be in scope, which could be provided by dioxus or by the renderer so it needs to manually imported.

@rMazeiks
Copy link
Contributor Author

rMazeiks commented Jul 1, 2022

dioxus_elements also needs to be in scope

This makes sense, since it is essentially used in user code (every time you type div you mean dioxus_elements::div or something). get_line_num is only in the generated code, and I agree that using the absolute path would be better because:

  • get_line_num might not be in scope
  • get_line_num might refer to something else in the scope, leading to weird issues

see also

@jkelleyrtp
Copy link
Member

I believe this is fixed? If it hasn't, it will be in #387

@jkelleyrtp jkelleyrtp added the core relating to the core implementation of the virtualdom label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core relating to the core implementation of the virtualdom
Projects
None yet
Development

No branches or pull requests

3 participants