Skip to content

Fix missing space between binary and unary operators in reconstruction#275

Open
kkozik-amplify wants to merge 1 commit intorelease/8.xfrom
operator-reconstruction
Open

Fix missing space between binary and unary operators in reconstruction#275
kkozik-amplify wants to merge 1 commit intorelease/8.xfrom
operator-reconstruction

Conversation

@kkozik-amplify
Copy link
Collaborator

Summary

  • Fix _should_add_space_before in HCLReconstructor to add space after binary operator tokens (e.g. &&, ||) when the next sibling is a Tree node (e.g. expr_term wrapping a unary_op)
  • Previously && !foo was reconstructed as &&!foo because the binary-op spacing logic only handled Token siblings, not Tree siblings
  • Add binary_op_before_unary test case to the smoke integration suite

Test plan

  • All 708 existing tests pass
  • New smoke test case covers && ! pattern in for-expression filter conditions
  • Verified reconstruction of multiline && !contains(...) expressions

🤖 Generated with Claude Code

…truction

The reconstructor's _should_add_space_before only checked for binary operator
spacing when the next sibling was a Token, but after operators like && the next
sibling can be a Tree (expr_term wrapping unary_op), causing "&&!foo" instead
of "&& !foo".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kkozik-amplify kkozik-amplify requested a review from a team as a code owner March 11, 2026 14:21
@kkozik-amplify
Copy link
Collaborator Author

while the parsing issue described in #246 is fixed as of v8.0.0rc2, this PR adds additional reconstruction fix on top of that

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.

2 participants