Closed alekseyt closed 5 years ago
Hello @alekseyt , welcome to {Syntax Highlighter}.
I'm afraid tree-sitter cannot handle throw
statements properly. It's a bug in tree-sitter.
I do not use exceptions at all, so I had no chance to check this.
Tree-sitter takes them for in-code declaration of function. In other words, the next two statements are syntactically the same:
throw std::runtime_error(message);
vs Type function(int);
The same happens with construction of variable as we have discussed in other issue. Class variable(parameter);
. But in the later case we can think of constructors as special functions, that have the same name as class.
the next two statements are syntactically the same
Except throw
is a keyword. But whatever, if it's an issue in tree-sitter then i'm closing this one.
I meant, the same for tree-sitter, of course (=. I collect such issues and intend to address them to tree-sitter community one day. Maybe in future they'll fix these issues.
Hi @alekseyt ,
I just wanted to let you know, that the latest version of tree-sitter-cpp fixes this issue.
I'll publish an update in a day.
Example code:
Screenshot:
Note that
1)
throw
is not a keyword 2)message
instd::runtime_error(message)
is highlighted in cyan for some reason (i have cyan assigned tosyntax.type
) 3)::
instd::runtime_error
is highlighted differently from::
instd::string
orstd::cout
Is this related to upstream tree-sitter or to this extension?
I've also tried to add
throw
to keywords:but this doesn't help.
Any ideas?