Skip to content

Fix floor division panic when only luau feature is enabled - #1192

Open
FelixDMxx wants to merge 1 commit into
JohnnyMorganz:mainfrom
FelixDMxx:fix/luau-floor-division-hang
Open

FelixDMxx wants to merge 1 commit into
JohnnyMorganz:mainfrom
FelixDMxx:fix/luau-floor-division-hang

Conversation

@FelixDMxx

Copy link
Copy Markdown

Fixes #1190

When StyLua is built with luau but not lua53, hanging a // expression (or formatting one with comments around the operator) panicked with unknown node DoubleSlash.

4bd007e enabled DoubleSlash for luau in expression.rs, but three trivia matches still only handled it under lua53: binop_trivia! in trivia.rs, and GetLeadingTrivia / GetTrailingTrivia for BinOp in trivia_util.rs. This gates DoubleSlash with any(feature = "luau", feature = "lua53") in all three, splitting it into its own arm where it was grouped with the lua53-only operators.

The existing floor-division.lua Luau test only had local x = 1 // 2, which never hangs. It now also covers a long // expression and comments around the operator.

BinOp::DoubleSlash is available with the luau feature, but the trivia
matches in trivia.rs and trivia_util.rs only handled it under lua53, so
hanging a `//` expression or formatting one with comments around the
operator panicked with "unknown node DoubleSlash" in luau-only builds.

Fixes JohnnyMorganz#1190

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic "unknown node DoubleSlash" when building with luau but not lua53

1 participant