diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dfe9539..0fbe20f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Luau: Fixed panic when formatting explicit type instantiation (`f<>()`) inside a nested function call argument (e.g. as a callback) ([#1088](https://github.com/JohnnyMorganz/StyLua/issues/1088)) + ## [2.4.0] - 2026-03-07 ### Added diff --git a/src/formatters/trivia_util.rs b/src/formatters/trivia_util.rs index 187ec80c..145cf577 100644 --- a/src/formatters/trivia_util.rs +++ b/src/formatters/trivia_util.rs @@ -156,6 +156,8 @@ fn is_expression_simple(expression: &Expression) -> bool { }, other => unreachable!("unknown node: {:?}", other), }, + #[cfg(feature = "luau")] + Suffix::TypeInstantiation(_) => true, other => unreachable!("unknown node: {:?}", other), }) } diff --git a/tests/inputs-luau/type-instantiation-in-callback.lua b/tests/inputs-luau/type-instantiation-in-callback.lua new file mode 100644 index 00000000..6831ea79 --- /dev/null +++ b/tests/inputs-luau/type-instantiation-in-callback.lua @@ -0,0 +1,4 @@ +-- Test for issue #1088: turbofish/TypeInstantiation inside nested function call +Charm.computed(function() + return createPluginSettingsStore<>("PresenceAuthStore", defaultValue, validate) +end) diff --git a/tests/snapshots/tests__luau@type-instantiation-in-callback.lua.snap b/tests/snapshots/tests__luau@type-instantiation-in-callback.lua.snap new file mode 100644 index 00000000..22011935 --- /dev/null +++ b/tests/snapshots/tests__luau@type-instantiation-in-callback.lua.snap @@ -0,0 +1,11 @@ +--- +source: tests/tests.rs +assertion_line: 36 +expression: "format(&contents, LuaVersion::Luau)" +input_file: tests/inputs-luau/type-instantiation-in-callback.lua +--- +-- Test for issue #1088: turbofish/TypeInstantiation inside nested function call +Charm.computed(function() + return createPluginSettingsStore<>("PresenceAuthStore", defaultValue, validate) +end) +