carbon-lang icon indicating copy to clipboard operation
carbon-lang copied to clipboard

Use `As` and `ImplicitAs` interfaces for conversions.

Open zygoloid opened this issue 1 year ago • 1 comments

Add these interfaces to the core library. For now, they're two separate interfaces because we don't yet support one interface extending another.

This collapses a lot of the layering in check: for example, the call building logic depends on implicit conversions, conversions now depend on the overloaded operator machinery, and that machinery depends on building calls.

In passing, improve the diagnostics for failing to find a name required from the prelude. Also convert all the transitively-called code from NodeId to LocId given the latter is what the conversion machinery has available.

zygoloid avatar Aug 09 '24 01:08 zygoloid

I've run out of time to work on this; if someone wants to take over while I'm on vacation that'd be great. The remaining issue is that at least one test crashes, but only when built with -c opt.

The crash is a CHECK failure:

CHECK failure at ./toolchain/base/value_store.h:174: id.index >= 0: instInvalidParseSubtree

coming from within a call to Convert. But that doesn't make any sense to me: instInvalidParseSubtree is meaningless, InvalidParseSubtree is a kind of Node, not a kind of Inst. Also, why does this only happen in an opt build? (The check message doesn't appear to end up in the log file unless a flush call is added to the crash handling machinery; I've pushed a change to do that.)

zygoloid avatar Aug 09 '24 22:08 zygoloid