[swift-dev] Unexpected Expr type
jordan_rose at apple.com
Thu Apr 6 17:49:51 CDT 2017
Hi, Halen. Welcome to the compiler. :-) What you're seeing is that we don't usually use C++'s normal RTTI <https://en.wikipedia.org/wiki/Run-time_type_information> mechanism, but instead go with a "Kind" field that's checked by the custom 'cast', 'dyn_cast', and 'isa' functions. (More information in the LLVM Programmer's Manual <http://llvm.org/docs/ProgrammersManual.html#the-isa-cast-and-dyn-cast-templates>.) The debugger doesn't know about this, so it just always shows the base class to be conservative. If you're debugging, you can call dump() to see what kind of Expr it really is, and then cast the pointer down to the right type as needed. In your actual code, you can check `isa<ParenExpr>(src)`, or `dyn_cast<ParenExpr>(src)` if you then need to manipulate the ParenExpr.
Hope that helps,
> On Apr 6, 2017, at 15:30, Halen Wooten via swift-dev <swift-dev at swift.org> wrote:
> Hi swift devs,
> I'm working on SR-4464 to learn how to contribute to Swift. I think I
> have the solution, but I'm getting unexpected results.
> I'm using the swift repl within Xcode for testing. Here's my test code.
> var name = "name"
> name = (name)
> In TypeChecker::diagnoseSelfAssignment in CSDiag.cpp, the src of the
> AssignExpr is a plain Expr *, but I would expect it to be a ParenExpr
> *. Could someone help me figure out what's happening?
> swift-dev mailing list
> swift-dev at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-dev