treesit_initialize ();
TSNode treesit_node = XTS_NODE (node)->node;
- /* ts_node_type could return NULL, see source code. */
+ /* ts_node_type could return NULL, see source code (tree-sitter can't
+ find the string name of a node type by its id in its node name
+ obarray). */
const char *type = ts_node_type (treesit_node);
return type == NULL ? Vtreesit_str_empty : build_string (type);
}
if (STRINGP (pred))
{
const char *type = ts_node_type (node);
+ /* ts_node_type returning NULL means something unexpected happend
+ in tree-sitter, in this case the only reasonable thing is to
+ not match anything. */
+ if (type == NULL) return false;
return fast_c_string_match (pred, type, strlen (type)) >= 0;
}
else if (FUNCTIONP (pred)
{
/* A bit of code duplication here, but should be fine. */
const char *type = ts_node_type (node);
+ /* ts_node_type returning NULL means something unexpected
+ happend in tree-sitter, in this case the only reasonable
+ thing is to not match anything */
+ if (type == NULL) return false;
if (!(fast_c_string_match (car, type, strlen (type)) >= 0))
return false;