Skip to content

Accessing a property of an uninitialized instance results in a Runtime error #70908

@Alc-Alc

Description

@Alc-Alc

Description

The code produces a runtime error instead of a compile-time error. I would anticipate this to be an error that could be identified during compile-time.

It's worth mentioning that removing the print and having just instance.x allows the compiled binary to execute without any runtime errors (exit code 0).

Reproduction

class SomeClass {
    let x: Int = 0
}

print(instance.x)
var instance = SomeClass()

Expected behavior

I expect this to be a compile-time error

Environment

swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SILaccepts invalidBug: Accepts invalidbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwaredefinite initializationArea → compiler → SIL: Definite initializationmemory safetyFeature: memory safetyscript modeFlag: Specific to script mode compilationswift 6.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions