Skip to content

[SR-1146] Enum with single case crashes when referenced as class property within initializer #43759

@swift-ci

Description

@swift-ci
Previous ID SR-1146
Radar None
Original Reporter flobraunschweig (JIRA User)
Type Bug
Status Reopened
Resolution

Attachment: Download

Environment

Xcode 7.3, Swift 2.2

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: b8a7dc0da5ceb86328da85d2daa4165f

Issue Description:

When using the following notation, the application crashes at runtime with a bad access exception:

App Delegate:

let a = EnumCrashTest()  // Runtime crash with bad access exception here!

A Class Definition:

enum SingleCaseEnum {
    case FirstCase
}
class EnumCrashTest {
    var singleCaseEnum: SingleCaseEnum
    
    init() {
        singleCaseEnum = .FirstCase
    }
}

The bug does not occur when using a struct instead of a class or if more than one cases are defined in the enumeration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions