Skip to content

Commit d441ef7

Browse files
facontidavideclaude
andcommitted
Fix misleading static_assert when extra args have wrong type (#837)
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 f20f2c3 commit d441ef7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ list(APPEND BT_SOURCE
155155
src/shared_library.cpp
156156
src/tree_node.cpp
157157
src/script_parser.cpp
158-
src/script_tokenizer.cpp
159158
src/json_export.cpp
160159
src/xml_parsing.cpp
161160

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)