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

Variable used before declaration cause crash in runtime on access, instead compilation error #73535

Open
krzyzanowskim opened this issue May 9, 2024 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels

Comments

@krzyzanowskim
Copy link
Contributor

Description

The variable used before declaration cause a crash in runtime on access instead of a compilation error.
Weird: It does not crash when build SwiftPM manifest, but it also does not throw a compilation error, instead ignores the variable value (example by https://gist.github.com/rnapier/1bf7a85eea76dc76fc61ad6aa0808fd2

Reproduction

class Foo {
    var settings: [String]
    
    init(_ settings: [String]) {
        self.settings = settings
    }
}

let f = Foo(s)
print(f.settings)
let s = ["a","b","c"]

Stack dump

Terminated due to signal: SEGMENTATION FAULT (11)

Expected behavior

compilation error. variable s used before declared.

Environment

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Additional information

No response

@krzyzanowskim krzyzanowskim added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels May 9, 2024
@snmb22
Copy link

snmb22 commented May 22, 2024

Terminated due to signal: SEGMENTATION FAULT (11)

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. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

2 participants