Skip to content

Conversation

karl-police
Copy link
Contributor

One assert less. 🤷

@karl-police
Copy link
Contributor Author

karl-police commented Jun 24, 2025

I think I forgot about writer.advance
I don't know what its purpose is meant to even be.

@vegorov-rbx
Copy link
Collaborator

vegorov-rbx commented Jul 21, 2025

This doesn't seem to cover all nodes we have for declaration files, so it's likely that someone making use of toString in a similar scenario will hit a different AstStatDeclare* case.

Something to consider, although this can be delegated to a separate PR (don't want to ask you to fix all missing nodes we have).

Having said that, this certainly misses a test case to validate that it works as intended.

Check out Transpiler.test.cpp test file and note that the transpile test method already accepts parse options so it should be possible to test with allowDeclarationSyntax option.

advance is used to preserve whitespace positions of the tokens.
It should be used when Position structure is available. Declaration nodes don't have detailed CST node info, but there still should be a starting token position at least.

@karl-police
Copy link
Contributor Author

karl-police commented Jul 22, 2025

Alright 👍

So, now I know the Transpiler is the thing that turns code into AST 🤔

@vegorov-rbx
Copy link
Collaborator

We might rename it in the future to be more clear.

Maybe something like AstStringEncoder to mirror AstJsonEncoder because it's just a serialization to a string source.
@aatxe probably would like that.

@vegorov-rbx vegorov-rbx merged commit b668ffb into luau-lang:master Jul 22, 2025
7 checks passed
@vegorov-rbx
Copy link
Collaborator

Thank you.

@karl-police karl-police deleted the patch-1 branch July 22, 2025 17:56
@aatxe
Copy link
Collaborator

aatxe commented Jul 22, 2025

Yeah, AstStringEncoder or AstPrettyPrinter or something would be great! :)

ayoungbloodrbx added a commit that referenced this pull request Jul 25, 2025
## General
- Support AstStatDeclareGlobal output as a source string (via
@karl-police in #1889)
- Luau heap dump correctly reports the size of a string, now including
overhead for the string type
- Prevent yields from Luau `xpcall` error handling function.
 
## Analysis
- Avoid exponential blowup when normalizing union of normalized free
variables.
- Fix type pack-related bugs that caused infinite recursion when:
  - A generic type pack was bound to itself during subtyping.
- In type pack flattening, when that same generic type pack was now
being bound another generic type pack which contained it.
- Properly simplify `any & (*error-type* | string)` to `*error-type* |
*error-type* | string` instead of hanging due to creating a huge union
type.

---

Co-authored-by: Andy Friesen <afriesen@roblox.com>
Co-authored-by: Ariel Weiss <aaronweiss@roblox.com>
Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Sora Kanosue <skanosue@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>

---------

Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com>
Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com>
Co-authored-by: Menarul Alam <malam@roblox.com>
Co-authored-by: Aviral Goel <agoel@roblox.com>
Co-authored-by: Vighnesh <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
Co-authored-by: Ariel Weiss <aaronweiss@roblox.com>
Co-authored-by: Andy Friesen <afriesen@roblox.com>
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