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-7184] #file doesn't match up with caller when in a larger expression #49732

Closed
swift-ci opened this issue Mar 13, 2018 · 0 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7184
Radar None
Original Reporter charlieMonroe (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

macOS 10.13.3, Xcode 9.3b3

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

md5: 95f7cf6745624d5e72b03540a1b25ba4

duplicates:

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

Issue Description:

I've been using a custom `fatalError` that I can catch and automatically send a report to myself. Something along this:

public func XUFatalError(_ additionalInformation: String = "", file: String = #file.components(separatedBy: "/").last!, line: Int = #line, method: String = #function) -> Never {
    // Gather this and send it.
}

When this is called, the #file is incorrectly always the name of the file that contains this function - however, removing `.components(separatedBy: "/").last!`, i.e. the default argument being simply `#file` correctly passes in the file of the caller.

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

No branches or pull requests

1 participant