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

Add ToStringOptions.hideFunctionSelfArgument #486

Merged
merged 1 commit into from
May 16, 2022

Conversation

JohnnyMorganz
Copy link
Contributor

Adds an option to hide the self: type argument as the first argument in the string representation of a named function type var if the ftv hasSelf.

Also added in a test for the original output (i.e., if the option was disabled)

I didn't apply this option in the normal Luau::toString() function, just the Luau::toStringNamedFunction() one (for my usecase, that is enough + I felt like a named function would include the method colon : to signify self). If this is unintuitive, I can also add it to the general Luau::toString() function.

@alexmccord
Copy link
Contributor

Thanks! I think it's okay to leave it out of Luau::toString().

@alexmccord alexmccord merged commit ab4bb35 into luau-lang:master May 16, 2022
@JohnnyMorganz JohnnyMorganz deleted the to-string-utils branch May 16, 2022 17:02
@andyfriesen
Copy link
Collaborator

It's a little bit weird that, when this option is set, the test method still shows a generic a that is not actually used in any of the displayed arguments or return type.

Probably okay, but something to be aware of.

@JohnnyMorganz
Copy link
Contributor Author

It's a little bit weird that, when this option is set, the test method still shows a generic a that is not actually used in any of the displayed arguments or return type.

Probably okay, but something to be aware of.

Valid point, I noticed this when I wrote the test (missed it out the first time). Wasn't sure on what to do here - I assume if we wanted to also hide this it would introduce quite a bit more complexity to the generics stringifier (need to check which generic to remove and only remove it if its not referenced anywhere)

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.

3 participants