-
Notifications
You must be signed in to change notification settings - Fork 445
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
Fixed bug in name resolution; better shadowing tests #349
Conversation
addToContext(c->type->typeParameters); | ||
addToContext(c->type->applyParams); | ||
addToContext(c->constructorParams); | ||
addToContext(c); // add the locals |
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.
@jnfoster: This change ensures that parameters enter the scope before the locals.
@@ -180,6 +180,7 @@ ResolveReferences::ResolveReferences(ReferenceMap* refMap, | |||
void ResolveReferences::addToContext(const IR::INamespace* ns) { | |||
LOG1("Adding to context " << dbp(ns)); | |||
BUG_CHECK(context != nullptr, "No resolution context; did not start at P4Program?"); | |||
checkShadowing(ns); | |||
context->push(ns); |
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 seems like this will now check every case of shadowing. Are there cases where shadowing should not be a warning? Actions in a control with the same name as some non-action global thing? Cases where a programmer might reasonably expect to reuse a name?
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.
All I can tell you is that there are no new warnings on the public tests we have.
If this is too strict we can refine it later.
continue; | ||
} | ||
if (pnode->is<IR::Type_Method>() && node->is<IR::Type_Method>()) | ||
// Methods can overload each other if they have a different number of arguments |
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.
@mbudiu-vmw You deleted the check that they have different numbers of parameters. Does this code now allow any pair of methods with the same name to shadow each other?
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 will just avoid giving a shadowing warnings for all methods.
There is another check somewhere that two methods may not have the same signature.
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 see.
Do you happen to know where that is?
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.
One case is in Type_Extern::lookupMethod.
I don't remember if there is another one.
This will signal an error only if the method is invoked.
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.
Cool. Thanks.
Also, make sure that type parameters, apply parameters and constructor parameters have distinct names.