Skip to content

Commit 2c71b41

Browse files
Fix misleading static_assert when extra args have wrong type (#837) (#1098)
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>
1 parent 8c18a27 commit 2c71b41

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

include/behaviortree_cpp/bt_factory.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,20 @@ class BehaviorTreeFactory
395395
"[registerNode]: you MUST implement the static method:\n"
396396
" PortsList providedPorts();\n");
397397

398-
static_assert(!(has_static_ports_list && !param_constructable),
398+
// When extra arguments were passed to registerNodeType but the full
399+
// constructor signature doesn't match, the problem is most likely a
400+
// type mismatch in those extra arguments (issue #837).
401+
static_assert(!(has_static_ports_list && !param_constructable
402+
&& sizeof...(ExtraArgs) > 0),
403+
"[registerNode]: the constructor is NOT compatible with the "
404+
"arguments provided.\n"
405+
"Verify that the types of the extra arguments passed to "
406+
"registerNodeType match\n"
407+
"the constructor signature: "
408+
"(const std::string&, const NodeConfig&, ...)\n");
409+
410+
static_assert(!(has_static_ports_list && !param_constructable
411+
&& sizeof...(ExtraArgs) == 0),
399412
"[registerNode]: since you have a static method providedPorts(),\n"
400413
"you MUST add a constructor with signature:\n"
401414
"(const std::string&, const NodeConfig&)\n");

0 commit comments

Comments
 (0)