-
Notifications
You must be signed in to change notification settings - Fork 207
gccrs: fix(type-check): Resolve 'exceptional' error_mark in visit pattern compilation #4376
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
base: master
Are you sure you want to change the base?
Conversation
P-E-P
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% confident because I'm not too familiar with that part of the codebase but it feels like you're trying here to fix the symptoms rather than the source of the problem.
816cbd4 to
23add0c
Compare
The compiler was throwing an ICE when a Type Alias was used as a value in a LetStmt (e.g., `let () = ::X = ();`). This occurred because the backend pattern compiler received an `error_mark_node` for the initialization expression and failed to handle it. This patch adds a check in `CompileStmt` to detect if the initialization expression is an `error_mark_node`. To prevent regression failures in other tests (excess errors), this check is restricted specifically to `TuplePattern`, which was the source of the crash. If detected, we now emit a proper error message and exit early. Fixes Rust-GCC#4161 gcc/rust/ChangeLog: * backend/rust-compile-stmt.cc (CompileStmt::visit): Check for error_mark_node in init expression for TuplePatterns and exit early if found. gcc/testsuite/ChangeLog: * rust/compile/issue-4161.rs: New test. Signed-off-by: Harishankar P P <harishankarpp7@gmail.com>
23add0c to
94c08f0
Compare
This comment was marked as outdated.
This comment was marked as outdated.
philberty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right place to check for this case, it should be in the PathInExpression piece it hits the code there for a more general case i think to start off to investigate there
| if (stmt.get_pattern ().get_pattern_type () | ||
| == HIR::Pattern::PatternType::TUPLE) | ||
| { | ||
| if (!seen_error ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isnt the right place to check for this i've loioked into this before there is a more general case we should be trying to catch this its during path code gen not stmt.
Also in your git commit subject you mention type-check.. this is not the type check pass.
|
@philberty Interesting !! Thanks for the pointer on the previous iteration! I’ve reverted the changes in It turned into a bit of a chain reaction to get this fully stable, but here is what I ended up doing:
3.Now the issue, which am facing is that it doesn't really throw up an error tbh, it let's it reside silently, which is indeed a huge issue. I will mark this as draft for now, and will let you know. |
This patch fixes two Internal Compiler Errors (ICEs) encountered during compilation.
First, it resolves a crash in
CompilePatternLet::visitwhere the backend panicked upon encountering anerror_marknode within a tuple pattern. A check was added to handle erroneous types gracefully.Second, it fixes a crash in the
MarkLivelint pass. Previously, visiting aTypeAliascould triggerrust_unreachable()if the AST-to-HIR mapping lookup failed. This assertion has been removed to allow the compiler to continue execution when the mapping is missing.Fixes #4161
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog:
Thank you for making Rust GCC better!
If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.
Here is a checklist to help you with your PR.
make check-rustpasses locallyclang-formatgcc/testsuite/rust/Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
*Please write a comment explaining your change. This is the message
that will be part of the merge commit.