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

Panic "Indexing into empty node" #282

Open
jDomantas opened this issue Feb 12, 2023 · 2 comments
Open

Panic "Indexing into empty node" #282

jDomantas opened this issue Feb 12, 2023 · 2 comments

Comments

@jDomantas
Copy link

This code:

use logos::Logos; // logos 0.12.1

#[derive(Logos)]
enum Token {
    #[regex("x()*")]
    What,
    #[error]
    Error,
}

Yields this compile error:

error: proc-macro derive panicked
 --> src\lib.rs:3:10
  |
3 | #[derive(Logos)]
  |          ^^^^^
  |
  = help: message: Indexing into an empty node. This is a bug, please report it at:

          https://github.com/maciejhirsz/logos/issues

error: could not compile `logos-bug` due to previous error

rustc version rustc 1.66.0 (69f9c33d7 2022-12-12)

@jeertmans
Copy link
Collaborator

Maybe that’s a bug, but your are trying to capture something that is empty. If you need to capture parentheses, you first need to escape them.

@jDomantas
Copy link
Author

I know that this particular regex is not something I want to write, I'm just reporting this because it's definitely a bug in the macro. For valid regexes it should compile, and for invalid ones it should show a reasonable error message (or at least point to the problematic regex), and in this case it is doing neither. Even better, the macro itself asks me to report this.

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

No branches or pull requests

2 participants