hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.88k stars 455 forks source link

fix(lib): correct the concat method in TokenizedStringFragments #3772

Open suojae opened 4 days ago

suojae commented 4 days ago

The concat method was not properly updating this.fragments because Array.prototype.concat returns a new array and does not modify the original array in place. Changed the implementation to use this.fragments.push(...other.fragments); to correctly merge the fragments into this.fragments.

Description

I thought concat method in TokenizedStringFragments was intended to merge fragments from another instance into this.fragments. However, it was not functioning correctly because Array.prototype.concat returns a new array and does not modify the original array in place.

To fix this issue, I updated the concat method to use this.fragments.push(...other.fragments);. This modifies this.fragments in place and ensures that all fragments are correctly merged.

Checklist

hashicorp-cla-app[bot] commented 4 days ago

CLA assistant check
All committers have signed the CLA.