-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --emit-lua-preserve-columns flag #572
base: master
Are you sure you want to change the base?
Conversation
Applies to `--only-check and `--emit-lua` flags. Caused one test to fail. Test case has been corrected.
Including test case.
Regarding the linting failure:
For me this is a false warning, since the whitespace is in a multi-line string and therefore has significance. That being said, the concern in the comments in |
I pushed the ugly `]] .. "\n" .. [[" fix. Another option is or course to remove the function return type annotation in the pallene code and the |
Instead of the In the driver code, the extra |
We could. Not sure where/how to do it cleanly… maybe as a second pass only to remove trailing whitespace, also applied to vanilla For my original motivation I guess it could make sense to remove for the types, to avoid lua tooling/linters complaining about the trailing whitespace. But for general removal, I'm less sure… there I guess I would maybe want the linter to complain since the whitespace was inserted by the programmer. 🤔 |
Will think and comment later about the driver code. My first thought when working on it was that at least "file extension" is the wrong level of abstraction for controlling the driver. Should be at minimum a string enum (which is basically what I used it as, I guess) or probably better a table? |
Or we could export a separate function for each task, instead of a do-all "compile" function. |
About whitespace, I'm curious which Lua linters complain about trailing whitespace. |
Luacheck, for one. https://luacheck.readthedocs.io/en/stable/warnings.html#formatting-issues-6xx |
I see... In that case I agree that we should not add spaces for type annotations, if those spaces would end up at the end of a line. If we remove all spaces at the end of lines, we will silence useful warnings. If we if don't then we'll introduce spurious warnings. Watch out for multi-line type annotations. Watch out for multi-line type annotations. |
Here is a draft implementation of the
--emit-lua-preserve-columns
flag proposed in #567. For your comments.I took largely the path of least resistance. The part that bothers me the most is the overloading of the
output_ext
to carry the flag, which is a bit of a hack. But I didn't want to embark on a more intrusive refactoring without bouncing it off you first.