-
-
Notifications
You must be signed in to change notification settings - Fork 377
Add support for Lua 5.5 #3218
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 support for Lua 5.5 #3218
Conversation
Co-authored-by: CppCXY <40318218+CppCXY@users.noreply.github.com>
Lua 5.5 introduced a new Lua syntax global x for declaring global variables.
Looking at the code:
function f() global y, print -- Declaring y and print as global variables function y() x = 123 --error print(x) end end
Co-authored-by: CppCXY <40318218+CppCXY@users.noreply.github.com>
Lua 5.5 introduced a new Lua syntax global x for declaring global variables.
Looking at the code:
...
I've added support for the new Lua 5.5 global
syntax. The implementation includes:
- Added
global
keyword to the parser with version restriction to Lua 5.5 only - Support for both
global var1, var2
declarations andglobal function
syntax - Proper error reporting when used with older Lua versions
- Intelligent completion suggestions that only appear when using Lua 5.5
The parser now correctly handles the syntax from your example:
function f() global y, print -- Declaring y and print as global variables function y() x = 123 --error print(x) end end
Implemented in commit 15c897a.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
- Triggering command:
/usr/lib/apt/methods/https
(dns block)
- Triggering command:
If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
Lua 5.5 introduce feature: for-loop variables are read only
.
Can you support check that?
Co-authored-by: CppCXY <40318218+CppCXY@users.noreply.github.com>
Lua 5.5 introduce feature:
for-loop variables are read only
.
Can you support check that?
I've implemented the read-only for-loop variables check for Lua 5.5. The diagnostic now detects when you try to assign to for-loop variables and reports an error with the message "Cannot assign to for-loop variable {}
(read-only in Lua 5.5)".
The implementation:
- Works for both numeric for-loops (
for i = 1, 10
) and for-in loops (for k, v in pairs(t)
) - Only triggers when using Lua 5.5 version setting
- Includes test cases and localized error messages
- Follows the existing diagnostic patterns in the codebase
Implemented in commit aa06ff5.
Co-authored-by: CppCXY <40318218+CppCXY@users.noreply.github.com>
There are some issues with global parsing: if it's not version 5.5, it shouldn't generate errors and should fall back to other branches directly. Users might write global = xxx
, and there's no global function
syntax, so don't add this during code completion.
...nt global function syntax Co-authored-by: CppCXY <40318218+CppCXY@users.noreply.github.com>
There are some issues with global parsing: if it's not version 5.5, it shouldn't generate errors and should fall back to other branches directly. Users might write
global = xxx
, and there's no `glob...
Fixed the global parsing issues:
- When version is not Lua 5.5, the parser now returns
nil, true
to indicate failed parse, allowing it to fallback to treatingglobal
as a regular identifier instead of generating errors - Removed the
global function
completion syntax as it doesn't exist in Lua 5.5 - Simplified the
parseGlobal()
function to only handleglobal var1, var2
declarations
The parser now properly handles global = xxx
expressions in non-5.5 versions without errors.
Implemented in commit aa69c2f.
please add this change to changelog
Co-authored-by: CppCXY <40318218+CppCXY@users.noreply.github.com>
please add this change to changelog
Added Lua 5.5 features to the changelog including runtime version support, global keyword syntax, and read-only for-loop variables diagnostic. Implemented in commit 78942bc.
global
can not be keyword, it maybe handle like goto
...a 5.5 context Co-authored-by: CppCXY <40318218+CppCXY@users.noreply.github.com>
global
can not be keyword, it maybe handle likegoto
Fixed the global parsing to handle like goto
- it's no longer treated as a keyword in the KeyWord table. Now global
only acts as a keyword when contextually appropriate (in Lua 5.5 with proper syntax), otherwise it falls back to being treated as a regular identifier. This allows expressions like global = xxx
to work correctly in all Lua versions. Implemented in commit a55f5e7.
readonly-for-loop-vars
should not be a diagnostic, it should report this error at the parser stage. Can you help me reimplement it?
Co-authored-by: CppCXY <40318218+CppCXY@users.noreply.github.com>
readonly-for-loop-vars
should not be a diagnostic, it should report this error at the parser stage. Can you help me reimplement it?
I've reimplemented readonly-for-loop-vars as a parser-stage error. The implementation now detects assignments to for-loop variables during parsing and reports a SET_FOR_LOOP_VAR
error with the message "Cannot assign to for-loop variable {}
(read-only in Lua 5.5)". The diagnostic implementation has been removed and tests updated accordingly. Implemented in commit 686aa5f.
I used up all my premium requests for this month just by playing around. I'm crying.
提交太大了。希望每个功能点是一个单独的PR。
这次还是先手动改了,下个版本再试试AI
Issues-translate-bot
commented
Jul 15, 2025
Sumneko Lua translate bot
The submission is too big. Hopefully each feature point is a separate PR.
This time I will change it manually first, and try AI in the next version
许愿未来把Lua新版本手册发给AI看,就能自动帮我实现所有功能
Issues-translate-bot
commented
Jul 15, 2025
Sumneko Lua translate bot
Make a wish to send the new version of Lua to AI in the future, and it will automatically help me realize all functions
Maybe we should wait until 5.5 is fully released? PUC-Rio is considering some changes to the syntax
Uh oh!
There was an error while loading. Please reload this page.
This PR adds comprehensive support for Lua 5.5 to the lua-language-server, allowing users to configure their runtime version to "Lua 5.5" and receive appropriate language support.
Changes Made
Configuration Support
"Lua.runtime.version": "Lua 5.5"
in their configurationLanguage Features
_VERSION
string definition in meta templateswarn()
function support (available in >5.4)Runtime Behavior
require()
function returnsunknown
type for second return valueDocumentation
Testing
All existing tests continue to pass, ensuring backward compatibility and that the new Lua 5.5 support doesn't break existing functionality for other Lua versions.
Example Usage
Fixes #3217.
💬 Share your feedback on Copilot coding agent for the chance to win a 200ドル gift card! Click here to start the survey.