mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 09:25:48 +01:00
Fix a lowering crash when lowering a return by reference of a type with an in-place initializing representation. We previously misinterpreted this as an in-place initializing return. This is addressed by changing lowering to interpret a `ReturnExpr` of a reference expression as a reference return. However, that exposes another issue: `return var;` produces a `ReturnExpr` of a reference expression in the case where it returns in place! To fix that, we switch `return var;` to producing a `ReturnExpr` of a value expression regardless of whether the function has a return slot. This makes the representation of `return var;` more uniform: * If the expression is a reference, we're performing a `ref` return. * If the expression is an initializing expression, we're performing a normal by-initialization return. * If the expression is a value expression, we're performing a `return var;`.