Skip to content

fix(hy-syntax): prevent parse_binary from folding binary operators across newlines (fixes #4327) - #4452

Open
SuperPiIot wants to merge 1 commit into
limitlessprojects:mainfrom
SuperPiIot:fix-issue-4327
Open

SuperPiIot wants to merge 1 commit into
limitlessprojects:mainfrom
SuperPiIot:fix-issue-4327

Conversation

@SuperPiIot

Copy link
Copy Markdown

Fixes #4327

Summary

  • Adds if !self.same_line_as_prev() || prec < min_prec in Parser::parse_binary (compiler/crates/hy-syntax/src/parser.rs) so that binary operator tokens starting a new line do not silently continue the previous expression across statement boundaries.
  • Preserves trailing operator continuation (e.g. a +\nb), where the binary operator remains on the same line as lhs.
  • Adds regression unit tests:
    • line_leading_binary_ops_do_not_fold_across_newlines: ensures c := a\n-b and d := a\n&b parse as separate statements rather than folding into binary expressions.
    • trailing_binary_op_before_newline_continues_onto_next_line: ensures c := a +\nb continues onto the next line as expected.

Verification

  • Tested with cargo test -p hy-syntax (118/118 passing, 0 failed).

Settlement Coords

  • Network: Base Mainnet (Chain ID 8453)
  • Asset: USDC
  • Address: 0xf084cF0076F91AA48C2370F427C399dAA8C1f07F

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.

[soundness] hy-syntax(parser): parse_binary folds line-leading -b and &b across newlines into binary expressions

1 participant