feat: checking for errors when calling ts_parser_set_language
#192
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently when calling
ts_parser_set_language, it can fail in these two cases:So, ideally, in go, we should report those errors to the user.
I've noticed that when using the default flags of the current
tree-sitter-cliand setting the language usinggo-tree-sitter,this lead to a segfault down the line, I think it is better to fail early in these cases.
Also I could reimplement the logic that the C side is doing in the go side so that we have more precise errors, but I think this would lead to possible inconsitencies if the C-side changes and the go-side lags behind, so I just returned a generic error saying that it could not set the language, but it could be because of the version.