-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ICE: "impossible range in AST" with a lone ...
(inclusive range syntax)
#32245
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
Comments
This is my fault. I thought I had prevented that case in the parser. |
In general, all kinds of weird things can be generated by syntax extensions, so erroneous situations are better tested post-expansion even if they can't be produced by the parser. |
@petrochenkov maybe I will loosen the restrictions in the parser and turn On Mon, Mar 14, 2016 at 12:38 PM, Vadim Petrochenkov <
|
I haven't looked carefully at this particular case, but probably yes. |
FYI, this is accepted as a valid Rust program: fn main() {
..;
0..;
..1;
0..1;
} |
@nodakai yeah, all types of half-open ranges are allowed but currently only On Mon, Mar 14, 2016 at 9:02 PM, Kai Noda [email protected] wrote:
|
Hmm actually the HIR lowering panics in several places (if it finds unexpanded macros etc) and doesn't seem to emit any errors or warnings currently, contradicting @petrochenkov's advice. I'm not even sure if the |
There is no convention for where well-formedness constraints on the AST/HIR should be enforced. I feel like the HIR lowering is a good place to do that since once we are in the compiler proper, the user is much less able to change things, whereas (as @petrochenkov points out) the parser can be subverted via syntax extensions. However, we are not very good at doing this. The span_err stuff should work fine everywhere in the compiler, and should definitely be OK to do in the HIR lowering. Note particularly on unexpanded macros, I think that is ok to assume, since it is guaranteed by the macro expander, not the parser and so cannot (afaik) be subverted by syntax extensions. However, if one wanted to be super-struct one could imagine a safety boundary between libsyntax and the compiler and then we should not assume all macros are expanded because it is enforced by libsyntax, not the compiler. |
@nrc How can I signal an error with just a |
@durka adding a |
@nrc well it is a |
Maybe just adding a |
The text was updated successfully, but these errors were encountered: