Fix misleading static_assert when extra args have wrong type by facontidavide · Pull Request #1098 · BehaviorTree/BehaviorTree.CPP · GitHub
Skip to content

Fix misleading static_assert when extra args have wrong type#1098

Merged
facontidavide merged 1 commit into
masterfrom
fix/837-misleading-static-assert-error
Feb 2, 2026
Merged

Fix misleading static_assert when extra args have wrong type#1098
facontidavide merged 1 commit into
masterfrom
fix/837-misleading-static-assert-error

Conversation

@facontidavide

@facontidavide facontidavide commented Feb 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Misleading assertion error on wrongly typed custom argument to class inheriting from ConditionNode #837: When registerNodeType<T> is called with extra constructor arguments of the wrong type, the compiler now shows a helpful message ("the constructor is NOT compatible with the arguments provided") instead of the misleading "you MUST add a constructor with signature: (const std::string&, const NodeConfig&)"
  • Splits the single static_assert into two: one for when extra args are provided (type mismatch), one for when no extra args are provided (missing constructor)
  • Also removes stale script_tokenizer.cpp reference from CMakeLists.txt left by the lexy removal

Test plan

  • Verify compile-time error message with mismatched extra arg types shows new message
  • Verify compile-time error message with missing constructor (no extra args) shows original message
  • Verify library builds cleanly with no regressions

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Added stricter compile-time validation for node factory registration with improved error messages to catch constructor signature mismatches earlier.

@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown

When registerNodeType is called with extra constructor arguments of the
wrong type, the compiler now reports that the extra arguments don't match
instead of the misleading "you MUST add a constructor" message.

Also remove stale script_tokenizer.cpp reference from CMakeLists.txt.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@facontidavide facontidavide force-pushed the fix/837-misleading-static-assert-error branch from d441ef7 to 885277a Compare February 2, 2026 18:22
@codacy-production

Copy link
Copy Markdown

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8c18a27) 5395 3755 69.60%
Head commit (885277a) 5395 (+0) 3755 (+0) 69.60% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1098) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@sonarqubecloud

sonarqubecloud Bot commented Feb 2, 2026

Copy link
Copy Markdown

@facontidavide facontidavide merged commit 2c71b41 into master Feb 2, 2026
19 checks passed
@facontidavide facontidavide deleted the fix/837-misleading-static-assert-error branch February 2, 2026 18:33
@codecov

codecov Bot commented Feb 2, 2026

Copy link
Copy Markdown

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.

Misleading assertion error on wrongly typed custom argument to class inheriting from ConditionNode

1 participant