Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upmacro future proofing: extend analysis to detect unfortunate interaction across arms #1464
Comments
This comment has been minimized.
This comment has been minimized.
|
cc #550 |
This comment has been minimized.
This comment has been minimized.
|
So from the previous issue, it seems the goal is to look at these two macro arms ($e:expr) => { ... }
($i:ident : $t:ty => { ... }and detect that the same input could be valid for both arms (assuming We have to be careful though, because macro evaluation is already dependent, and usefully so, on the order of the arms, for example this pattern: (A ...) => { /* case A */ }
(B ...) => { /* case B */ }
($i:ident ...) => { /* other */ } |
This comment has been minimized.
This comment has been minimized.
|
Also, are there ideas on how to do the actual ambiguity checking? Not sure if we know what class of parsers |
This comment has been minimized.
This comment has been minimized.
I haven't put much thought into it, but I am willing to use a conservative analysis that just emits a lint style warning to the macro author. (And never make it an error by default in rustc) (Also, another potential option that has been suggested: expand the macro input matching system so that the expander can "back out" of one arm and try the next. (Ie it becomes a backtracking parser) I am not saying the latter is my preferred solution, but it will be good for us to consider all options when we tackle this problem. ) |
This comment has been minimized.
This comment has been minimized.
DanielKeep
commented
Jan 18, 2016
|
Backtracking would definitely be the preferred solution. Without it, for example, there's no way to parse generic parameters in |
This comment has been minimized.
This comment has been minimized.
|
cc #1384 |
pnkfelix commentedJan 15, 2016
spawned off of rust-lang/rust#30531 (comment)
(transcribed relevant material from that comment below.)