Skip to content

Conversation

suojae
Copy link
Contributor

@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

Copy link

hashicorp-cla-app bot commented Nov 17, 2024

CLA assistant check
All committers have signed the CLA.

@DanielMSchmidt
Copy link
Contributor

Hey, thanks for your help! Could you add a test case that shows which user-facing issue this fix solved so that we don't reintroduce the problem by accident in the future?

@suojae
Copy link
Contributor Author

suojae commented Nov 25, 2024

Hi, thank you for your feedback! I have written a test case for the concat method to verify the user-facing issue is resolved. Could you confirm where exactly I should add the test code? I assume it should go into packages/cdktf/test/tokens/string-fragments.test.ts, but please let me know if there's a more appropriate location.

Copy link
Contributor

github-actions bot commented Mar 8, 2025

Hi there! 👋 We haven't heard from you in 60 days and would like to know if you're still working on this or need help. If we don't hear from you before then, I'll auto-close this PR in 30 days.

@github-actions github-actions bot added the stale An issue or pull request that has not been updated in a very long time label Mar 8, 2025
@github-actions github-actions bot removed the stale An issue or pull request that has not been updated in a very long time label Mar 28, 2025
suojae added 2 commits April 2, 2025 13:30
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.
Added a test case to verify that the `concat` method correctly merges fragments from another instance.
@xiehan xiehan force-pushed the fix/concat-method branch from bb927b6 to eb67df8 Compare April 2, 2025 11:30
@xiehan xiehan merged commit 8ea05e2 into hashicorp:main Apr 2, 2025
430 of 431 checks passed
Copy link
Contributor

github-actions bot commented May 3, 2025

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants