mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Unify initialization and conversion logic (#3255)
Combine the initialization, implicit conversion, and value category conversion functions into a single function. This substantially reduces the duplication between these steps, and ensures that we support the same set of conversions in all these contexts. This also fixes some issues where we would not use the proper value representation for tuples and structs after performing implicit conversions.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/sem_ir/node.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
@@ -28,7 +29,7 @@ auto HandleVariableDeclaration(Context& context, Parse::Node parse_node)
|
||||
context.AddNameToLookup(var.parse_node(), name_id, var_id);
|
||||
// If there was an initializer, assign it to storage.
|
||||
if (has_init) {
|
||||
init_id = context.Initialize(parse_node, var_id, init_id);
|
||||
init_id = Initialize(context, parse_node, var_id, init_id);
|
||||
// TODO: Consider using different node kinds for assignment versus
|
||||
// initialization.
|
||||
context.AddNode(SemIR::Node::Assign::Make(parse_node, var_id, init_id));
|
||||
|
||||
Reference in New Issue
Block a user