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

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

Closed
Alc-Alc opened this issue Jan 13, 2024 · 2 comments
Closed
Labels
accepts invalid Bug: Accepts invalid bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software definite initialization Area → compiler → SIL: Definite initialization duplicate Resolution: Duplicates another issue memory safety Feature: memory safety script mode Flag: Specific to script mode compilation SIL swift 6.0

Comments

@Alc-Alc
Copy link

Alc-Alc commented Jan 13, 2024

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

@Alc-Alc Alc-Alc added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jan 13, 2024
@jamieQ
Copy link
Contributor

jamieQ commented Jan 15, 2024

same issue as #70380 i believe

@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue compiler The Swift compiler itself definite initialization Area → compiler → SIL: Definite initialization accepts invalid Bug: Accepts invalid SIL memory safety Feature: memory safety swift 6.0 crash Bug: A crash, i.e., an abnormal termination of software global let & var Feature: global constants and variables and removed triage needed This issue needs more specific labels labels Feb 29, 2024
@AnthonyLatsis
Copy link
Collaborator

Duplicate of #70323

@AnthonyLatsis AnthonyLatsis marked this as a duplicate of #70323 Feb 29, 2024
@AnthonyLatsis AnthonyLatsis closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
@AnthonyLatsis AnthonyLatsis added script mode Flag: Specific to script mode compilation and removed global let & var Feature: global constants and variables labels Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepts invalid Bug: Accepts invalid bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software definite initialization Area → compiler → SIL: Definite initialization duplicate Resolution: Duplicates another issue memory safety Feature: memory safety script mode Flag: Specific to script mode compilation SIL swift 6.0
Projects
None yet
Development

No branches or pull requests

3 participants