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-155] REPL: Summary string not being displayed for all struct names #4552

Closed
swift-ci opened this issue Dec 9, 2015 · 5 comments
Closed
Labels

Comments

@swift-ci
Copy link

swift-ci commented Dec 9, 2015

Previous ID SR-155
Radar None
Original Reporter MatiMax (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Linux 4.2.0-18-generic #22-Ubuntu SMP Fri Nov 6 18:25:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug, Linux, REPL
Assignee granataenrico (JIRA)
Priority Medium

md5: 8bd91f558571b08051eea978d5766f67

Issue Description:

While in the Swift REPL defining a struct and creating a new value the evaluation of the value results in an error.

1> struct Point {
2.    var x: Float, y: Float 
3.    var d: Float { return y - x } 
4. }
5> var p = Point(x: -2.0, y: 3.0)
p: Point = error: summary string parsing error
6> print(p)
Point(x: -2.0, y: 3.0)
@swift-ci
Copy link
Author

Comment by Matthias M. Schneider (JIRA)

If you rename Point to, for example, Pnt then the stuct will be evaluated correctly and printed without producing the error.

@swift-ci
Copy link
Author

Comment by Enrico Granata (JIRA)

Hi,
I am one of the engineers that work on the Swift REPL

I can reproduce the issue you're presenting and it is an issue with the LLDB data formatters subsystem

We have a set of builtin data formatters that help us pretty print different data types (for instance, the elements in a Swift array, or the contents of an NSString, ...)
One of those data formatters is for a type named 'Point' that comes from some old Mac OS X framework
It is defined thusly: `(v=${var.v}, h=${var.h})`
In the LLDB formatters syntax, this means that your point shall be printed as the string "(v=" followed by the value of the member "v" of your Point variable, the string ", h=" the value of your Point variable's "h" member, and then a closed parenthesis

In your example, the Point type you defined has neither a ".v" nor a ".h" member, so the LLDB formatter gets confused, and emits a print error instead of just falling back to normal printing

The workaround is to - before defining your Point structure - type at the REPL prompt:

:type summary delete -l objc Point

I can see a few ways to improve this experience here, and I am going to hold on to this issue so that I can actively track these possible avenues

Thanks for your report!

@swift-ci
Copy link
Author

Comment by Matthias M. Schneider (JIRA)

Hi Enrico,

thanks for looking into this and the workaround. I would never have thought along those lines given that a newly started REPL session explicitly tells me that Point is an "unresolved identifier" and as such I was happily playing along with the struct using this name. 😉

Your explanation is clear to me and I hope you and the team can fix this issue in the near future.

Cheers,

Mati

@swift-ci
Copy link
Author

Comment by Matthias M. Schneider (JIRA)

The issue seems to be solved in snapshot 2016-01-11-a on Ubuntu 15.10.

@swift-ci
Copy link
Author

Comment by Matthias M. Schneider (JIRA)

The issue seems to be fixed in current builds of Swift 2.2 and Swift 3.0.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from swiftlang/swift May 7, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant