Open msteindorfer opened 1 year ago
/cc @rxwei @DougGregor
Minimal repro (but without the crash):
/Users/rxwei/Development/Swift/swift-source/swift/test/Macros/macros_diagnostics.swift:70:80: error: unexpected error produced: generic parameter 'T' could not be inferred
@freestanding(expression) macro usesAssocType<T: BinaryInteger>: T.Magnitude = #externalMacro(module: "MissingModule", type: "MissingType")
Basically, anything that has an associated type at the return position triggers it.
Description
Type checking the following macro declaration fails with the error message
"Generic parameter 'T' could not be inferred"
:Note, that there is no generic type
T
mentioned in the signature, thus, the error might possibly originate from the#externalMacro
or type-checking of the result thereof.As an alternative I tried to remove the
#externalMacro
and go back to directly assigning the implementation:This leads to a compiler error:
LLVM_SYMBOLIZER_PATH
to point to it): 0 swift-frontend 0x0000000104e17a78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 swift-frontend 0x0000000104e16cfc llvm::sys::RunSignalHandlers() + 128 2 swift-frontend 0x0000000104e180b8 SignalHandler(int) + 304 3 libsystem_platform.dylib 0x00000001a86482a4 _sigtramp + 56 4 libsystem_pthread.dylib 0x00000001a8619cec pthread_kill + 288 5 libsystem_c.dylib 0x00000001a85522c8 abort + 180 6 swift-frontend 0x00000001052826d0 (anonymous namespace)::Verifier::verifyChecked(swift::VarDecl) (.cold.1) + 0 7 swift-frontend 0x00000001017398b0 (anonymous namespace)::Verifier::verifyChecked(swift::ValueDecl) + 284 8 swift-frontend 0x00000001017332b0 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl) + 4320 9 swift-frontend 0x000000010173b168 (anonymous namespace)::Traversal::doIt(swift::Decl) + 288 10 swift-frontend 0x000000010173b03c swift::Decl::walk(swift::ASTWalker&) + 32 11 swift-frontend 0x00000001018f902c swift::SourceFile::walk(swift::ASTWalker&) + 236 12 swift-frontend 0x0000000101728e00 swift::verify(swift::SourceFile&) + 96 13 swift-frontend 0x00000001019ff404 swift::TypeCheckSourceFileRequest::cacheResult(std::__1::tuple<>) const + 76 14 swift-frontend 0x0000000101544740 llvm::ExpectedSteps to reproduce
swift-DEVELOPMENT-SNAPSHOT-2023-01-30-a-osx
snapshot toolchain#regex
type signature given earlier on, or transform on of the standard examples, like#stringify
to use generics in a similar fashion, e.g.:Actually, even more simplified, just referencing the associated type
T.RegexOutput
makes the declaration already fail:Expected behavior The
#regex
macro declaration is supposed to type-check, not cause Xcode warning, or Swift compiler errors.Environment