Skip to content

Conversation

@Janther
Copy link
Contributor

@Janther Janther commented Jan 28, 2026

In this comment I was made aware that prettier can be run asynchronously.

When parsing, we recollect data from our AST tree, that if run in parallel jobs, will generate errors in formatting.

Right now our parsing is not async so there shouldn't be any issue. but if at any point slang or prettier decide that their API should be asynchronous, we must address this.

This solution changes the signature of the constructor of nodes, making it necessary the passing of Prettier's options object which is unique per job.

The important changes happen in src/slang-nodes/SlangNode.ts (where we collect the data), src/slangSolidityParser.ts (where we used to clear the data for the next run), and src/types.d.ts (where we define the type that will contain the data). Everywhere else the changes are just to modify the constructor signature and initiate each new node with the options object.

I didn't want to complicate the signatures of the nodes' constructor and already half of the nodes receive the Prettier options object. Using an _prettier_solidity_ to prepend the names of the attributes seemed like a good enough solution but I'm willing to revisit this if we decide is safer in another way.

@Janther Janther requested a review from fvictorio January 28, 2026 20:27
@Janther Janther mentioned this pull request Jan 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