From 2e8b009167a2af7aeaecffbd1e2a811c6f8a1280 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 22 Mar 2026 11:31:03 -1000 Subject: [PATCH] fix duplication --- esphome/cpp_generator.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index a32cd945d4..2937a43754 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -598,13 +598,11 @@ def Pvariable(id_: ID, rhs: SafeExpType, type_: "MockObj" = None) -> "MockObj": MockObj(f"{storage_id.id}.get()"), ) ) - # Extract args from the CallExpression and rebuild as placement new + # Extract args from the CallExpression and rebuild as placement new. + # Template args are already encoded in the_type (e.g. GlobalsComponent), + # so we only pass the constructor args, not template_args. call_expr = rhs.base # CallExpression("new Type", args...) - placement_args: list[Expression] = [] - if call_expr.template_args is not None: - placement_args.append(call_expr.template_args) - placement_args.extend(call_expr.args) - placement_new = CallExpression(f"new({id_.id}) {the_type}", *placement_args) + placement_new = CallExpression(f"new({id_.id}) {the_type}", *call_expr.args) CORE.add(ExpressionStatement(placement_new)) else: decl = VariableDeclarationExpression(id_.type, "*", id_, static=True)