Skip to content

Conversation

wmccrthy
Copy link
Contributor

@wmccrthy wmccrthy commented Sep 22, 2025

This PR adds a printType function to the printer API. I've been working with the visitor, parser and printer APIs a bunch, and the need for this has come up a few times.

This PR also consolidates some repeated logic used across the printing functions

Copy link
Collaborator

@aatxe aatxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me besides the type comment.


--- Returns a string representation of an AstExpr
function printExpr(block: luau.AstExpr): string
function printNode(node: luau.AstExpr | luau.AstStat | luau.AstType, visit: any): string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we do a more precise type for visit here? Looks like it expects a node and a buffer, and returns nothing, so... (node: ..., printer: buffer) -> ()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, we definitely can. How about:

function printNode<T>(node: T, visit: (node: T, visitor: visitor.Visitor) -> ()): string

@aatxe aatxe merged commit 774eba7 into luau-lang:primary Sep 22, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants