Skip to content

Fix script compare with negative number exception #896

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

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/t09_scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static const char* xml_text = R"(
<Sequence>
<Script code=" msg:='hello world' " />
<Script code=" A:=THE_ANSWER; B:=3.14; color:=RED " />
<Precondition if="A>B && color != BLUE" else="FAILURE">
<Precondition if="A>-B && color != BLUE" else="FAILURE">
<Sequence>
<SaySomething message="{A}"/>
<SaySomething message="{B}"/>
Expand Down
6 changes: 3 additions & 3 deletions include/behaviortree_cpp/scripting/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,9 @@ struct Expression : lexy::expression_production
dsl::op<Ast::ExprComparison::greater_equal>(LEXY_LIT(">"
"="));

// The use of dsl::groups ensures that an expression can either contain math or bit
// The use of dsl::groups ensures that an expression can either contain math or bit or string
// operators. Mixing requires parenthesis.
using operand = dsl::groups<math_sum, bit_or>;
using operand = dsl::groups<math_sum, bit_or, string_concat>;
};

// Logical operators, || and &&
Expand All @@ -808,7 +808,7 @@ struct Expression : lexy::expression_production
dsl::op<Ast::ExprBinaryArithmetic::logic_or>(LEXY_LIT("||")) /
dsl::op<Ast::ExprBinaryArithmetic::logic_and>(LEXY_LIT("&&"));

using operand = dsl::groups<string_concat, comparison>;
using operand = comparison;
};

// x ? y : z
Expand Down
Loading