-
Notifications
You must be signed in to change notification settings - Fork 163
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
Add late name resolution pass #2620
Conversation
DefaultResolver::visit (let); | ||
|
||
// how do we deal with the fact that `let a = blipbloup` should look for a | ||
// label and cannot go through function ribs, but `let a = blipbloup()` can? |
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.
let a = blipbloup
can look through function ribs if blipbloup
is a function, constant or static item.
@@ -54,6 +63,11 @@ TopLevel::insert_or_error_out (const Identifier &identifier, const T &node, | |||
void | |||
TopLevel::go (AST::Crate &crate) | |||
{ | |||
// we do not include builtin types in the top-level definition collector, as |
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.
use i32;
is allowed for editions >= 2018
auto def_fn = [this, &function] () { | ||
for (auto ¶m : function.get_function_params ()) | ||
{ | ||
// TODO: So extern function params are not patterns? |
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.
Rustc will parse any pattern, but it's an error if the pattern is anything other than an identifier or _
after expansion.
// so what is the plan for glob imports | ||
// 1. figure out the rib which contains all the exports, in each namespace | ||
// 2. for that namespace, go through all the nodes | ||
// 3. filter out the exported ones (is that correct?) |
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.
It should be all nodes that are visible (not private) from the import, even other imports. You do need to handle cycles somehow.
|
||
auto candidate = nr_ctx.values.to_rib (body_mappings.get_nodeid ()); | ||
|
||
// FIXME: Ugly |
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.
😆
177a4b3
to
5cd813b
Compare
Isn't this C++17 ? Won't it break with 4.8 ? |
yeah, this does break it. I'll remove the commits. it's very useful for testing however and works in C++11, the compiler just complains that this attribute is in C++17 and still applies it |
2854b1b
to
6c2145f
Compare
6c2145f
to
08f26b4
Compare
@matthewjasper I opened issues for all your comments, but I don't think I'll be addressing them in this PR as the goal for this one is to not add any regressions, and thus it can be in an incomplete state. thanks a lot for having taken the time to review it :) |
a79741a
to
83b9bac
Compare
01755c2
to
6a5265e
Compare
6a5265e
to
bf97c5e
Compare
bf97c5e
to
022d75c
Compare
The resolver did report duplicate symbols when being run multiple times even if the node id was the same. This commit adds an additional condition, the error will only be reported if the existing node id is different from the current node id. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::insert_or_error_out): Add new constraint to duplicate errors. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Change the test's name resolution algorithm to 2.0. gcc/testsuite/ChangeLog: * rust/compile/name_resolution12.rs: Add name resolution 2.0 flag. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Change test name resolution algorithm to 2.0. gcc/testsuite/ChangeLog: * rust/compile/name_resolution13.rs: Add compile flag to use the new name resolution 2.0 algorithm. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
The compiler did not emit any warning when a same target was declared from different sources. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_dec): Use the new dict to track down already resolved use declarations. * resolve/rust-toplevel-name-resolver-2.0.h: Add new dict to store previous use declarations. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
The original error text did not match the test nor rustc's behavior. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Update error text to match rustc's one. gcc/testsuite/ChangeLog: * rust/compile/name_resolution14.rs: Update the test with error code. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Change the name resoltion algorithm to 2.0 in this test. gcc/testsuite/ChangeLog: * rust/compile/name_resolution14.rs: Add flag to activate name resolution 2.0. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Change name resolution algorithm in name resolution test 18 to the new name resolution 2.0. gcc/testsuite/ChangeLog: * rust/compile/name_resolution17.rs: Add flag to use new name resolution algorithm. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Change the name resolution algorithm to name resolution 2.0 in one name resolution test. gcc/testsuite/ChangeLog: * rust/compile/name_resolution18.rs: Add flag to enable name resolution algorithm. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
The resolver was emitting an error when meeting the same symbol twice. What is important here is the origin of the resolved symbol, we should emit an error when the name is similar but the symbol isn't be not when the resolver is simply meeting the exact same symbol. gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (insert_macros): Add constraint over the ast node id. (TopLevel::visit): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
@CohenArthur Should we close this PR ? |
This is a massive draft PR which I'll split in multiple tinier ones
visit_function_param
helper functionget
for Namespace::LabelsUseDeclaration
sfind_starting_point
[other functions too?]