Skip to content
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

[SR-10075] Can't emit an implicit value constructor with generic type parameters and default value. #52477

Closed
kateinoigakukun opened this issue Mar 10, 2019 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis

Comments

@kateinoigakukun
Copy link
Member

Previous ID SR-10075
Radar None
Original Reporter @kateinoigakukun
Type Bug
Status Resolved
Resolution Done
Environment

macOS: 10.14.3(18D109)
swift-5.0-DEVELOPMENT-SNAPSHOT-2019-03-06-a

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @slavapestov
Priority Medium

md5: 11348b8bb1454f63cbaf6514c9920798

Issue Description:

This is crashing code.

func defaultValue<T>() -> T {
    fatalError()
}

struct S<T> {
    let value1: T = defaultValue()
    let value2: Int
}

func main() {
    _ = S<Int>(value2: 1)
}
Assertion failed: (fieldTy->isEqual(field->getParentInitializer()->getType()) && "Checked by sema"), function emitImplicitValueConstructor, file /Users/kateinoigakukun/projects/swift-source/swift/lib/SILGen/SILGenConstructor.cpp, line 144.
Stack dump:
0.  Program arguments: /Users/yuutas4/projects/swift-source/build/Xcode-DebugAssert/swift-macosx-x86_64/Debug/bin/swift -frontend -c -primary-file Sources/sil_crash/sil_crash.swift -target x86_64-apple-darwin18.2.0 -enable-objc-interop -color-diagnostics -module-name sil_crash -o /var/folders/36/f44c1x4d081f4l5zmx_68x5w0000gn/T/sil_crash-a611e0.o
1.  While silgen emitConstructor SIL function "@$s9sil_crash1SV6value2ACyxGSi_tcfC".
 for 'init(value2:)' (at Sources/sil_crash/sil_crash.swift:5:8)
0  swift                    0x000000011706205c llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
1  swift                    0x00000001170625b9 PrintStackTraceSignalHandler(void*) + 25
2  swift                    0x000000011705fb86 llvm::sys::RunSignalHandlers() + 118
3  swift                    0x000000011706355e SignalHandler(int) + 190
4  libsystem_platform.dylib 0x00007fff67a4bb3d _sigtramp + 29
5  swift                    0x000000011114072d llvm::DenseMapInfo<swift::Type>::getHashValue(swift::Type) + 29
6  libsystem_c.dylib        0x00007fff679091c9 abort + 127
7  libsystem_c.dylib        0x00007fff678d1868 basename_r + 0
8  swift                    0x000000010f94845a emitImplicitValueConstructor(swift::Lowering::SILGenFunction&, swift::ConstructorDecl*) + 2762
9  swift                    0x000000010f94622b swift::Lowering::SILGenFunction::emitValueConstructor(swift::ConstructorDecl*) + 155
10 swift                    0x000000010f8d44fb swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)::$_4::operator()(swift::SILFunction*) const + 539
11 swift                    0x000000010f8b56ff void emitOrDelayFunction<swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)::$_4>(swift::Lowering::SILGenModule&, swift::SILDeclRef, swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*)::$_4&&, bool) + 831
12 swift                    0x000000010f8b4cd3 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 947
13 swift                    0x000000010fa9c5f7 (anonymous namespace)::SILGenType::visitConstructorDecl(swift::ConstructorDecl*) + 39
14 swift                    0x000000010fa9b96c swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 876
15 swift                    0x000000010fa93f3e (anonymous namespace)::SILGenType::emitType() + 158
16 swift                    0x000000010fa93e6a swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 42
17 swift                    0x000000010f8df228 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visitStructDecl(swift::StructDecl*) + 40
18 swift                    0x000000010f8bc401 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 225
19 swift                    0x000000010f8bbf4e swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 622
20 swift                    0x000000010f8bcdea swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 538
21 swift                    0x000000010f8bd7bb swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&) + 59
22 swift                    0x000000010e40bae7 generateSILModules(swift::CompilerInvocation&, swift::CompilerInstance&) + 887
23 swift                    0x000000010e4024b2 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1554
24 swift                    0x000000010e4010b5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2421
25 swift                    0x000000010e3396b2 run_driver(llvm::StringRef, llvm::ArrayRef<char const*>) + 914
26 swift                    0x000000010e3380f3 main + 2723
27 libdyld.dylib            0x00007fff67860ed9 start + 1
28 libdyld.dylib            0x000000000000000d start + 2558128437
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

To reproduce this crash, use

@belkadan
Copy link
Contributor

Huh. @slavapestov, @jckarter, is that use of isEqual correct, or do we need a generic signature as well?

@slavapestov
Copy link
Member

#23754

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants