Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

confusing error message from clone! #597

Closed
bilelmoussaoui opened this issue Feb 18, 2020 · 5 comments · Fixed by #609
Closed

confusing error message from clone! #597

bilelmoussaoui opened this issue Feb 18, 2020 · 5 comments · Fixed by #609

Comments

@bilelmoussaoui
Copy link
Member

I have tried to use the clone! macro with two use cases and I'm getting a confusing error message

test case 1

clone!(@strong row_sender => async move {
                    google_font.download().await.and_then(|()| {
                        send!(row_sender, RowAction::Installed);
                        Ok(())
                    });
                });

test case 2

       let on_entry_changed = clone!(@weak self.fg_entry, self.bg_entry => move |_entry: &gtk::Entry| {
            let fg_colour = fg_entry.get_text();
            let bg_colour = bg_entry.get_text();

            state.borrow_mut().set_bg_colour(Some(&bg_colour));
            state.borrow_mut().set_fg_colour(Some(&fg_colour));

            send!(sender, Action::ColorChanged);
        });

In both cases I'm getting Variables need to be valid identifiers, e.g. field accesses are not allowed as is, you must rename it! which is a bit confusing

@sdroege
Copy link
Member

sdroege commented Feb 18, 2020

The second one seems to tell you exactly what you did wrong there :) You need to rename the fields.

The first should work as is in that regard, but you have to provide a closure and not an async block. So the error message could be improved a bit there.

@GuillaumeGomez
Copy link
Member

And for the first, I think the macro is failing to detect the missing "|whatever|" block.

@sdroege sdroege mentioned this issue Feb 19, 2020
40 tasks
@sdroege
Copy link
Member

sdroege commented Mar 12, 2020

@GuillaumeGomez Is this fixed now with the latest change?

@GuillaumeGomez
Copy link
Member

Checking.

@GuillaumeGomez
Copy link
Member

The first test case now says "no rules expected the token `async`". The second says what it should. I'm adding a test case for the first just in case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants