luafmt: preserve_statement_semicolon = false removes a required `;` before a `(` statement, output no longer parses
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start with append_trailing_statement_semicolon in formatter/render/comments.rs, which returns early when preserve_statement_semicolon is off. Reproduce with the two-line input in the issue using a config file that sets preserve_statement_semicolon = false. Done when the ; before a statement starting with ( survives, and it is still removed in other cases.
Written by the indexing model from the issue text.
Description
With preserve_statement_semicolon = false (the default in --dump-default-config), luafmt removes a ; that Lua needs: one that separates a statement from a following statement starting with (. The output no longer parses.
printf '[output]\npreserve_statement_semicolon = false\n' > cfg.toml
printf 'local req = f()\n;(req).style = 1\n' | luafmt --config cfg.toml
Actual:
local req = f()
(req).style = 1
which Lua reads as f()(req).style = 1: luajit reports unexpected symbol near '='. Expected: the ; is kept (e.g. local req = f();), as it is when no config file is given.
The removal is unconditional (append_trailing_statement_semicolon in formatter/render/comments.rs returns early when the option is off). A ; should be dropped only when the next statement does not start with (.
luafmt 0.25.1.
- Dominant language
- Rust
- Stars
- 517
- Forks
- 101
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 18
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from EmmyLuaLs/emmylua-analyzer-rust
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
EmmyLuaLs/emmylua-analyzer-rust#1276 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
EmmyLuaLs/emmylua-analyzer-rust#1249 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
EmmyLuaLs/emmylua-analyzer-rust#1247 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
EmmyLuaLs/emmylua-analyzer-rust#1016 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
EmmyLuaLs/emmylua-analyzer-rust#1303 ·
Maintainers usually reply within 1 day
All issues in EmmyLuaLs/emmylua-analyzer-rust
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
AimesSoft/NipaPlay-Reload#1022 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ZcashFoundation/frost-tools#612 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
ScoopInstaller/Extras#19070 ·
Maintainers usually reply within 1 day
-
test: sim_zero_omega_tests race on shared temp-file names, so two pairs of tests fail at randomOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100