Fix #1029: correct left-associativity for arithmetic operators by facontidavide · Pull Request #1069 · BehaviorTree/BehaviorTree.CPP · GitHub
Skip to content

Fix #1029: correct left-associativity for arithmetic operators#1069

Merged
facontidavide merged 1 commit into
masterfrom
fix/issue-1029
Feb 1, 2026
Merged

Fix #1029: correct left-associativity for arithmetic operators#1069
facontidavide merged 1 commit into
masterfrom
fix/issue-1029

Conversation

@facontidavide

@facontidavide facontidavide commented Feb 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix left-to-right associativity for +, -, *, / operators in the script parser
  • A - B + C was incorrectly evaluated as A - (B + C) due to conflicting binding power levels in lexy's operation list
  • Adds regression tests for arithmetic associativity

Test plan

  • New test: ScriptParser.Associativity_Issue1029
  • All existing tests pass (298/298)

Closes #1029

Summary by CodeRabbit

  • Bug Fixes

    • Fixed operator associativity handling in scripting, resolving precedence conflicts with string concatenation and arithmetic operations.
  • Tests

    • Added test suite validating left-associativity for arithmetic and string operations (Issue1029).

✏️ Tip: You can customize this high-level summary in your review settings.

…ipt parser

The scripting engine evaluated "A - B + C" as "A - (B + C)" instead of
"(A - B) + C". The root cause was that string_concat's operand chain
referenced math_sum, causing it to appear twice in lexy's operation list
with conflicting binding power levels. Changed string_concat::operand
from math_sum to math_prefix to eliminate the duplicate entry.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 1, 2026

Copy link
Copy Markdown

@facontidavide facontidavide merged commit 51df1e0 into master Feb 1, 2026
11 of 12 checks passed
@facontidavide facontidavide deleted the fix/issue-1029 branch February 1, 2026 17:29
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.

Mathematical order of opperations in script is wrong

1 participant