Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/AST/Mangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ void Mangler::mangleEntity(const ValueDecl *decl,
unsigned uncurryLevel) {
assert(!isa<ConstructorDecl>(decl));
assert(!isa<DestructorDecl>(decl));

// entity ::= static? entity-kind context entity-name
if (decl->isStatic())
Buffer << 'Z';
Expand All @@ -1603,7 +1603,12 @@ void Mangler::mangleEntity(const ValueDecl *decl,
return mangleAccessorEntity(accessorKind, func->getAddressorKind(),
func->getAccessorStorageDecl());
}


// Avoid mangling nameless entity. This may happen in erroneous code as code
// completion.
if (!decl->hasName())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it not have a name? Would it be better to ensure a name is always set? Or maybe we shouldn't be trying to mangle the entity in the first place? Or perhaps we should fix the mangler to just not allow this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to improve the mangler to allow nameless entities, in this test case let:{. As far as i know, we don't have a default name to set on the var decl lead by let, so to fix mangler to be more forgiving is a reasonable solution.

return;

if (isa<VarDecl>(decl)) {
Buffer << 'v';
} else if (isa<SubscriptDecl>(decl)) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
// REQUIRES: asserts
var d{let:{func a#^A^#
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
{let:{class S(}#^A^#