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-15758] Fast path does not take effect cause no return. #4357

Open
swift-ci opened this issue Jan 20, 2022 · 0 comments
Open

[SR-15758] Fast path does not take effect cause no return. #4357

swift-ci opened this issue Jan 20, 2022 · 0 comments

Comments

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented Jan 20, 2022

Previous ID SR-15758
Radar None
Original Reporter Meng94 (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Improvement
Assignee None
Priority Medium

md5: f7cfd73ccf04d925250424b0e281cf7a

Issue Description:

Summary: It is not take effect in swift-tools-support-core UNIXPath fast init.
Description: UNIXPath in Path.swift line 562, called `self.init(string: path)`, but no return, this cause no effect with fast path.

private struct UNIXPath: Path {
    // ...
    // Fast path
    init(normalizingAbsolutePath path: String) {
        // ...
        if !mayNeedNormalization(absolute: path) {
            self.init(string: path) 
            // no return to take effect.
        }
        // ...

        self.init(string: result)
    }
}

I write demo and output like this:

struct Test {
    let string: String


    init(string1: String) {
        self.string = string
    }


    init(string2: String) {
        if string2 == "1" {
            self.init(string1: string2 + " with if")
            // return
        }
        self.init(string1: string2 + " without if")
    }
}

print(Test(string2: "1").string) // '1 without if', which should be '1 with if' when add return.
print(Test(string2: "2").string) // '2 without if'
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants