Open P-E-P opened 1 year ago
hey @P-E-P , I am not sure how I should go about it, because the rustc also catches this as a lexical error. :3
@mvvsmk with the following code:
fn foo() {
let a = 15q;
}
and running rustc
with -Z parse-only
, we don't get any error. so the parsing is correct, but rustc
has an extra AST validation step that checks that the suffix is correct.
I'm not sure if this is overkill and if we should just have a parsing error. This is probably useful for custom suffixes and future suffix developments in Rust, but we won't have changes like these in gccrs
- we'll only reflect what rustc
is doing
@mvvsmk with the following code:
fn foo() { let a = 15q; }
and running
rustc
with-Z parse-only
, we don't get any error. so the parsing is correct, butrustc
has an extra AST validation step that checks that the suffix is correct.I'm not sure if this is overkill and if we should just have a parsing error. This is probably useful for custom suffixes and future suffix developments in Rust, but we won't have changes like these in
gccrs
- we'll only reflect whatrustc
is doing
Not only custom suffixes, procedural macros are impacted by this behavior.
@CohenArthur I'll start working on this could you assign this to me.
@P-E-P could you hellp me out a bit https://github.com/Rust-GCC/gccrs/blob/3fcd86e404cac6763e40ca032aff942a3da09666/gcc/rust/lex/rust-lex.cc#L1221-L1227 just removing the rust_error_at would remove the error , is there any specific info you would like me to return in the case of an unkown suffix?
just removing the rust_error_at would remove the error , is there any specific info you would like me to return in the case of an unkown suffix?
Tbh it's been a while since I've created this issue. IIRC this was because proc macros content should be relaxed and the suffixes should be rejected later (when ? during ast validation ?).
You'll have to rework the token structure in order to store custom suffixes. From here I see two ways of doing it:
CORETYPE_CUSTOM_SUFFIX
?)
I would probably go with solution 2 for now, it'll be easier and such a refactor could be done later anyway.
Do not hesitate to ask more questions about this, it's been a while and I may have forgotten some details.
Thanks for the detailed response. I'll try and implement solution 2 and will ping you if I run into something odd. Most likely the thing that seems difficult is to catch the things that might fail silently, but I'll get to that when I am done with a rough solution.
GCCRS lexer refuses literals with an unknown suffixes.
I tried this code:
-frust-compile-until=ast
I expected to see this happen: Parse correctly.
Instead, this happened:
Meta