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-3040] Variable used within its own initial value error for functions with labels #45630

Closed
swift-ci opened this issue Oct 25, 2016 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself parser Area → compiler: The legacy C++ parser

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-3040
Radar None
Original Reporter auswahlaxiom (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

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

md5: 00174ded9b49d35cdb4b17b1a07190ed

duplicates:

  • SR-1846 "Variable used in its own initial value" error when using a function (not a variable) of the same name

Issue Description:

If you try to assign the result of a function that has argument labels to a variable with the same name as the first part of the function, it does not compile, with the error: "Variable used within its own initial value".

Example:

struct Person {
    let firstName: String
    let lastName: String
}

func name(for person: Person) -> String {
    return person.firstName + " " + person.lastName
}

let ada = Person(firstName: "Ada", lastName: "Turner")
let name = name(for: ada) // Variable used within its own initial value
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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. compiler The Swift compiler in itself parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

1 participant