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
4 changes: 4 additions & 0 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3997,6 +3997,10 @@ namespace {
auto results = namelookup::lookupMacros(CurDC, DeclNameRef(moduleName),
DeclNameRef(macroName), roles);
for (const auto &result : results) {
// Ignore invalid results. This matches the OverloadedDeclRefExpr
// logic.
if (result->isInvalid())
continue;
OverloadChoice choice = OverloadChoice(Type(), result, functionRefKind);
choices.push_back(choice);
}
Expand Down
24 changes: 24 additions & 0 deletions test/Constraints/issue-77393.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// RUN: %target-typecheck-verify-swift

// https://github.com/swiftlang/swift/issues/77393
// Make sure we don't crash.

@freestanding(expression)
macro someMacro() = #externalMacro(module: "", type: "")
// expected-warning@-1 {{external macro implementation type '.' could not be found for macro 'someMacro()'; plugin for module '' not found}}
// expected-note@-2 {{'someMacro()' previously declared here}}
// expected-note@-3 {{'someMacro()' declared here}}

@freestanding(expression)
macro someMacro() = #externalMacro(module: "", type: "")
// expected-error@-1 {{invalid redeclaration of 'someMacro()'}}
// expected-warning@-2 {{external macro implementation type '.' could not be found for macro 'someMacro()'; plugin for module '' not found}}

#someMacro()
// expected-error@-1 {{external macro implementation type '.' could not be found for macro 'someMacro()'; plugin for module '' not found}}

macro invalidMacro()
// expected-error@-1 {{macro 'invalidMacro()' requires a definition}}
// expected-error@-2 {{macro 'invalidMacro()' must declare its applicable roles via '@freestanding' or @attached'}}

#invalidMacro() // expected-error {{no macro named 'invalidMacro'}}