When evaluating expressions, lldb has to replicate the context in which the expression is being run. For instance, if you are stopped in a method of a class, you expect to be able to refer to ivars transparently, and method lookup has to be done looking up the class hierarchy.
Sometimes lldb can't figure out the context, and our failed attempt to wrap your expression in the right context produces expressions that don't compile. That's what you are seeing.
For instance, people started doing:
guard let self = self! {}
in closures that capture self weakly. The presence of two self's threw this context reconstruction for a loop. And there are many other subtleties that lldb has to get right. Swift is a fairly complex language in this regard.
So if you are seeing this in a particular context, you've likely found another manifestation of this problem. Be sure you try the most recent Xcode if you can, since lldb has fixed a goodly number of this sort of bug recently. If it still doesn't work, please do file a bug, either with http://bugs.swift.org or using Apple's feedback system.
BTW, if you just need to examine variables, the command frame var
(aliased to v
in recent lldb's will often work when print
fails, since it doesn't do most of the complex tricks the expression parser has to do. v
is also generally much quicker, since it just examines memory rather than building up, compiling, injecting and running an expression in the debugee...