logos
logos copied to clipboard
Derive macro panics due to reserved node merge in invalid alternation
More specifically, the derive macro panics when there is an invalid alternation present within a subpattern's repetition, and that subpattern is later repeated.
error: proc-macro derive panicked
--> src\main.rs:7:10
|
7 | #[derive(Logos)]
| ^^^^^
|
= help: message: Merging two reserved nodes! This is a bug, please report it:https://github.com/maciejhirsz/logos/issues
This is the minimum I was able to cause a panic with:
#[derive(Logos)]
#[logos(subpattern example = r"(a|)+")]
enum Example {
#[regex("(?&example)+")]
Subpattern,
#[error]
Error,
}
Notably, removing the repetition in Subpattern
(like below) appears to cause compilation to hang forever:
#[derive(Logos)]
#[logos(subpattern example = r"(a|)+")]
enum Example {
#[regex("(?&example)")]
Subpattern,
#[error]
Error,
}
I was able to avoid a panic by removing the alternation:
#[derive(Logos)]
#[logos(subpattern example = r"(a)+")]
enum Example {
#[regex("(?&example)+")]
Subpattern,
#[error]
Error,
}
I've tested with both rustc 1.57.0 (f1edd0429 2021-11-29)
(latest stable at time of writing) and rustc 1.58.0-nightly (c9c4b5d72 2021-11-17)
(ol' reliable) and the issue appears to remain. I'm unsure if it's a compiler bug, but given the above I assume it's Logos-related. Both rustc versions are of the x86_64-pc-windows-gnu
variety.