Target first attribute at_sign in stmt_remove_leading_newlines for LocalFunction/ConstFunction#1115
Merged
Merged
Conversation
…or LocalFunction/ConstFunction When a LocalFunction or ConstFunction has a leading Luau attribute (e.g. @Native), the actual first token of the statement is the attribute's at_sign, not the local/const keyword. stmt_remove_leading_newlines was targeting the wrong token, leaving stray newlines before the attribute at the start of a block. Fixes #1109
…cation on no-attribute path - Deduplicate the identical 6-line attribute-stripping logic from LocalFunction and ConstFunction arms into a single helper function - Use peekable iterator so no Vec is allocated when the function has no attributes (the common case) - Make both arms use a consistent if-let pattern instead of early-return vs if/else - Remove redundant comment from test input file
Replace peek()+collect()+[0]+clone() with cloned().next()? which takes the first element as an owned value so with_at_sign can consume it directly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1115 +/- ##
=======================================
Coverage 96.66% 96.66%
=======================================
Files 16 16
Lines 5307 5308 +1
=======================================
+ Hits 5130 5131 +1
Misses 177 177 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a LocalFunction or ConstFunction has a leading Luau attribute (e.g. @Native),
the actual first token of the statement is the attribute's at_sign, not the local/const
keyword. stmt_remove_leading_newlines was targeting the wrong token, leaving stray
newlines before the attribute at the start of a block.
Fixes #1109