Skip to content

Store a mapping to ensure no two symbols map to the same metadata - #500

Merged
maxbrunsfeld merged 1 commit into
masterfrom
dedup-symbols
Dec 6, 2019
Merged

maxbrunsfeld merged 1 commit into
masterfrom
dedup-symbols

Conversation

@maxbrunsfeld

@maxbrunsfeld maxbrunsfeld commented Dec 6, 2019 •

Copy link
Copy Markdown
Contributor

This PR ensures that the ts_node_symbol and ts_language_symbol_for_name APIs will always maintain a 1:1 correspondence between numeric symbols and names.

Previously, when aliases were used in certain ways (see #197), it was possible for two numeric symbols to have the same public-facing node type. One place this is currently visible is in the Python grammar, in the parenthesized_expression rule, due to this alias.

Similarly to #334, #469, and #475, there are ABI compatibility concerns surrounding this change, so the feature is gated behind a --next-abi feature flag to the generate command. Like those other PRs, this PR adds support for the behavior in the runtime, but does not change the output of tree-sitter generate for now. Very soon, I'm going to enable this whole batch of features by default, and bump the ABI versions of newly generated parsers. Then, we will be able to start taking advantage of this change.

@maxbrunsfeld

Copy link
Copy Markdown
Contributor Author

/cc @tclem - This PR fixes that issue that we worked around in haskell-tree-sitter where the SymbolMatching instances had to keep track of multiple symbols. We'll need to keep that workaround for a while, but once all of the parsers are updated with this change, we'll be able to remove it.

@maxbrunsfeld
maxbrunsfeld merged commit 1c8aed7 into master Dec 6, 2019
@maxbrunsfeld
maxbrunsfeld deleted the dedup-symbols branch December 6, 2019 17:51
maxbrunsfeld added a commit to tree-sitter/node-tree-sitter that referenced this pull request Dec 6, 2019
maxbrunsfeld added a commit that referenced this pull request Jan 27, 2020
Previously, this didn't correctly handle the case where *multiple* 
symbols were all simply-aliased to the same *other* symbol.

Refs #500
tmiland pushed a commit to atomeditor-io/node-tree-sitter that referenced this pull request Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants