Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] semantic: restrict SymbolTable and ScopeTree APIs #6052

Closed
DonIsaac opened this issue Sep 25, 2024 · 2 comments
Closed

[RFC] semantic: restrict SymbolTable and ScopeTree APIs #6052

DonIsaac opened this issue Sep 25, 2024 · 2 comments
Labels
A-semantic Area - Semantic C-enhancement Category - New feature or request

Comments

@DonIsaac
Copy link
Collaborator

Problems

  1. All fields of SymbolTable are pub. Because of this, we can't make refactors without breaking our API and possibly even downstream code. Note that members of ScopeTree and Semantic are not externally visible.
  2. Many mutable methods are pub. The transformer and oxc_traverse need some of these, but I doubt they need all of them

Proposed Solutions

For point one, we should make all fields of SymbolTable pub(crate). This will require a refactor in oxc_transform and oxc_traverse to use existing read methods. It is also a breaking change in the semver-major sense.

For point two, I see two possible approaches. The hiccup is that traverse/transform need mutable access to symbols and scopes.

1. Make mut methods not used in traverse/transform pub(crate)

Simple API reduction. This is likely the easiest, and wouldn't require changes to other crates in the monorepo. It also provides the least benefit.

2. Move oxc_traverse into oxc_semantic

Moving traversal code into oxc_semantic would let us make all &mut methods on semantic objects pub(crate). Our consumer-facing/external API for mutating these objects could then only be impls on Traverse. This is, however, a much larger refactor and may not be worth it.

Thoughts?

@DonIsaac DonIsaac added C-enhancement Category - New feature or request A-semantic Area - Semantic labels Sep 25, 2024
@overlookmotel
Copy link
Collaborator

Don and I discussed on a call yesterday. I absolutely agree that SymbolTable's fields should not be pub. We need the ability to change the underlying implementation of Semantic without it being a breaking change to public APIs.

However, we agreed that we should do a wider revamp of Semantic along the lines of #6077 rather than piecemeal changes, to reduce churn for external consumers.

@DonIsaac If #6077 is a fair representation of our discussion yesterday, would it make sense to close this issue in favour of that one?

@DonIsaac
Copy link
Collaborator Author

Closing in favor of #6077

@DonIsaac DonIsaac closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-semantic Area - Semantic C-enhancement Category - New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants