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-10951] Value of #file/#line/#column/#function change when used from expression #53342

Closed
swift-ci opened this issue Jun 17, 2019 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

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

Attachment: Download

Additional Detail from JIRA
Votes 1
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 3de8b4cf94eb450bdca6bce3ba7ec3bd

duplicates:

  • SR-6913 Default arguments are not evaluated correctly in larger expression

Issue Description:

Values of #file/#line/#column/#function are different depending on context.

Consider two functions:

public func log(file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) {
    print(file + ":\(function)" + ":\(column)" + ":\(line)")
}

public func log2(descriptor: String = #file + ":\(#function)" + ":\(#column)" + ":\(#line)") {
    print(descriptor)
}

Should these two functions print identical results? As of Xcode 10.2.1 values are different. Default values for `log` are evaluated in context of caller, when values for `log2` are evaluated in context of callee. Please see playground reproducing this in the attachment.

@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.
Projects
None yet
Development

No branches or pull requests

1 participant