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-4325] Changed value of #file on 3.1 snapshot #46908

Closed
swift-ci opened this issue Mar 23, 2017 · 6 comments
Closed

[SR-4325] Changed value of #file on 3.1 snapshot #46908

swift-ci opened this issue Mar 23, 2017 · 6 comments
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-4325
Radar rdar://problem/31312300
Original Reporter ylin (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.1Regression
Assignee None
Priority Medium

md5: e313b742e7d7e12c484bcff6f2434dca

is duplicated by:

  • SR-4459 Source location literals not set (#file, #function, #line)

Issue Description:

Here is an example main.swift:

print("From inside main.swift: #file - \(#file)")

class Test {
    let file = #file
}

print("From inside Test class: #file - \(Test().file)")

On 3.0.2, this prints out:
From inside main.swift: #file - /Users/ylin/Swift/Bugs/file-is-empty/Sources/main.swift
From inside Test class: #file - /Users/ylin/Swift/Bugs/file-is-empty/Sources/main.swift

On 3.1-DEVELOPMENT-SNAPSHOT-2017-03-19-a, this prints out:
From inside main.swift: #file - /Users/ylin/Swift/Bugs/file-is-empty/Sources/main.swift
From inside Test class: #file -

This code prints out an empty string for the `#file` debug symbol inside the class on 3.1 snapshot, on both OSX and Ubuntu 16.04, which is contrary to its behavior on 3.0.2.

Is this compiler change intentional?

@belkadan
Copy link
Contributor

No, definitely seems like a bug!

@swift-ci
Copy link
Collaborator Author

Comment by Youming Lin (JIRA)

I just checked the 3.1 GM toolchain and this bug is still present for both macOS and Ubuntu 16.04. Is there any plan to fix this?

@jckarter
Copy link
Member

@swift-ci create

@jckarter
Copy link
Member

jckarter commented Apr 6, 2017

Testing a fix: #8589

@jckarter
Copy link
Member

jckarter commented Apr 6, 2017

As a workaround in this particular case, you could put the #file reference in another function that gets called from the `=` expression. The bug is localized to inside initializer expressions for stored properties.

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented May 15, 2018

This has been fixed for a while. Closing.

@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

3 participants