Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

suojae
Copy link

@suojae suojae commented Nov 17, 2024

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

  • I have updated the PR title to match CDKTF's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

The concat method was not properly updating `this.fragments` because `Array.prototype.concat` does not modify the original array in place. Changed the implementation to use `push` with the spread operator to correctly merge fragments.
Copy link

hashicorp-cla-app bot commented Nov 17, 2024

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant