You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
swift-ci opened this issue
Oct 25, 2016
· 0 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfparserArea → compiler: The legacy C++ parser
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
The text was updated successfully, but these errors were encountered:
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfparserArea → compiler: The legacy C++ parser
Attachment: Download
Additional Detail from JIRA
md5: 00174ded9b49d35cdb4b17b1a07190ed
duplicates:
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:
The text was updated successfully, but these errors were encountered: