-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Basic name poisoning support #4654
Conversation
carbon-language#4622 When using an unqualified name disallow using that name in all scopes that would make it ambiguous in retrospect. Doesn't include support for poisoning when importing (see new test for that with TODO). Implemented by introduce `InstId::PoisonedName` and entries with it to `NameScope`.
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.
Looks good! This made me think a little more about what's needed to get a good diagnostic -- some comments inline, sorry I didn't think about that before.
toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon
Show resolved
Hide resolved
toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon
Outdated
Show resolved
Hide resolved
toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon
Show resolved
Hide resolved
toolchain/check/testdata/function/declaration/no_prelude/name_poisoning.carbon
Outdated
Show resolved
Hide resolved
* Use `llvm::SmallVector` instead of `std::vector`. * Put `DeclNameStack::NameContext::State::Poisoned` before `DeclNameStack::NameContext::State::Unresolved`. * Fix comment style and grammar. * Remove `InstId::PoisonedNameIndex`. * Use "non-poisoned" instead of "non poisoned".
…ote to the place where the name is declared after it was poisoned.
Can you take a look at the test failures? |
…age#4657) For example, format the `ImplicitAs` interface as `Core.ImplicitAs` rather than simply `ImplicitAs`. When importing an entity in a namespace, also import a declaration of the enclosing namespace if necessary so that we can determine its name.
This is essentially the result of looking at `.begin()` uses. We also frequently do `std::shuffle`, but unfortunately STLExtras doesn't provide a wrapper for that.
Found by fuzzer. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
…phization fails. (carbon-language#4662) Also fix a bug in `Context::GetClassType` that previously tried to complete the class type before returning it. That's not correct -- `GetCompleteTypeImpl` is only appropriate for cases where the type can trivially be completed and completing it can't fail -- and led to infinite recursion with this change because we would call `GetClassType` when producing a diagnostic if completing that class type failed.
…oCompleteType`. (carbon-language#4670) Almost all callers actually could never fail and nearly all of those already `CHECK`-failed on failure. Add a new overload for that case, and add a location parameter for the one remaining call.
- Provide `Check::Dump(context, arg)` and similar. - gdb and lldb should do contextual lookup, and `call Dump(*this, Lex::TokenIndex::Invalid)` has been tested with gdb. - Since this is only for debug, keeps the functions fully separated from code. - Uses alwayslink to ensure objects are correctly linked, even though there are no calls. - `-Wno-missing-prototypes` is needed when we don't have forward declarations. - Code is not linked in opt builds, using `#ifndef NDEBUG`. - This probably could be doing something in BUILD files with a `select()`, but the `#ifndef` seemed easier. This is based on carbon-language#4620, but uses free functions instead of member functions. Co-authored-by: Dana Jansens <danakj@orodu.net> --------- Co-authored-by: danakj <danakj@orodu.net>
…rbon files (carbon-language#4667) This would be used to test interop with C++. carbon-language#4666
…-language#4677) This is so that diagnostics which lack a location get split file clustering.
Given code like the following: ``` auto kind = ConversionTarget::Kind{0}; CARBON_CHECK(!loc_id.is_valid(), "hello {0} world", kind); ``` Currently we would print 'hello <the next line>', as the check string would be treated as terminating at the '{0}', so it does not print the rest of the string or a newline. This is because ConversionTarget::Kind is an enum with underlying type `int8_t` which is a char, and llvm::formatv does not look if the type is an enum and treat is specially. So it prints it as a char rather than a number, which in this case is a nul terminator. With this change, the '{0}' value will be converted to a larger integer before being passed through to llvm::formatv so that char-sized enums will print as a number, and the result is that we will print 'hello 0 world\n' as the developer intended.
If the user's fork is not named 'origin' then the script will fail and needs to know the user's remote name. Fixes carbon-language#1899
The call got misplaced during refactoring.
…4686) Such indexing operations are created by array initialization. Since we switched integer literals to be of type IntLiteral we've been attempting to index arrays with the (empty) representation of an IntLiteral rather than with an actual integer value.
Head branch was pushed to by a user without write access
Thanks! |
I see this failed on another merge conflict. I've merged to try to get it in now. The contributor access should help avoid this repeating, though; I encourage resolving conflicts & merging after approval, now that you can. :) |
And maybe I just missed that I hadn't approved... |
Thanks for the merge Jon! |
#4622
When using an unqualified name, disallow declaring that name in all scopes that would make it ambiguous in retrospect.
Doesn't include support for poisoning in
impl library
(see new test for that with TODO).Implemented by introduce
InstId::PoisonedName
and entries with it toNameScope
.