Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added option `block_newline_gaps` to determine whether newline gaps at the start / end of blocks should be preserved. Defaults to `Never`, which is the original behaviour. ([#857](https://github.com/JohnnyMorganz/StyLua/pull/857))

### Fixed

- Fixed formatting of index containing brackets string in parentheses ([#992](https://github.com/JohnnyMorganz/StyLua/pull/992))
- Fixed goto not being recognised for LuaJIT ([#986](https://github.com/JohnnyMorganz/StyLua/issues/986))
- Fixed semicolon removed after a statement ending with an if-expression leading to ambiguous syntax when the next line begins with parentheses ([#1010](https://github.com/JohnnyMorganz/StyLua/issues/1010))

## [2.1.0] - 2025-04-21

Expand Down
4 changes: 4 additions & 0 deletions src/formatters/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ fn expression_ends_with_identifier_or_parentheses(expression: &Expression) -> bo
Expression::UnaryOperator { expression, .. } => {
expression_ends_with_identifier_or_parentheses(expression)
}
#[cfg(feature = "luau")]
Expression::IfExpression(if_expression) => {
expression_ends_with_identifier_or_parentheses(if_expression.else_expression())
}
_ => false,
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/inputs-luau/ambiguous-syntax-1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- https://github.com/JohnnyMorganz/StyLua/issues/1010
(child :: BasePart).Size = if true then x else y;
(child :: BasePart).CFrame = value
8 changes: 8 additions & 0 deletions tests/snapshots/tests__luau@ambiguous-syntax-1.lua.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
source: tests/tests.rs
expression: "format(&contents, LuaVersion::Luau)"
input_file: tests/inputs-luau/ambiguous-syntax-1.lua
---
-- https://github.com/JohnnyMorganz/StyLua/issues/1010
(child :: BasePart).Size = if true then x else y;
(child :: BasePart).CFrame = value
Loading