Skip to content

新增 syntaxCompatibility 配置项:显式指定使用调试目标解释器解析源码 - #358

Open
sumneko wants to merge 2 commits into
masterfrom
syntax-compatibility
Open

新增 syntaxCompatibility 配置项:显式指定使用调试目标解释器解析源码#358
sumneko wants to merge 2 commits into
masterfrom
syntax-compatibility

Conversation

@sumneko

@sumneko sumneko commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

之前解析文件时只使用默认解释器。如果调试目标使用了自定义语法,那么将会解析失败,导致断点无法生效。

本次改动:

  • 新增 launch 配置项 syntaxCompatibility(默认关闭)。开启后使用调试目标的解释器执行 load + string.dump,为断点生成行号信息(恢复此前删除的 eval.dump 机制)。
  • 修复 undump55 的字符串缓存未重置问题:多次解析时缓存跨调用残留,导致内存累积与字符串索引错位。

注意:该配置只能解决语法解析问题,无法解决字节码格式不兼容的情况。

Copilot AI lite review requested due to automatic review settings September 2, 2026 08:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new dump/error-propagation and undump paths can mask real syntax errors and can throw on unsupported bytecode formats without graceful handling, which risks breaking breakpoint calculation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds an opt-in syntaxCompatibility launch configuration to improve breakpoint line mapping when the debug target uses non-default Lua syntax, by optionally compiling/dumping via the target VM; also fixes a Lua 5.5 undump string-cache retention issue to avoid cross-call leakage.

Changes:

  • Introduces syntaxCompatibility config plumbing (schema + i18n) and propagates it into breakpoint line-info parsing.
  • Restores an eval.dump-based path to obtain dumped bytecode for line-info generation.
  • Resets undump55’s internal string cache per invocation to prevent memory growth and index mismatches across parses.
File summaries
File Description
extension/script/backend/worker/undump.lua Resets Lua 5.5 undump string cache per call to avoid cross-parse cache corruption/leaks.
extension/script/backend/worker/parser.lua Adds optional target-VM dumping path for syntax compatibility during line-info generation.
extension/script/backend/worker/eval/dump.lua New helper chunk used to compile + dump source content.
extension/script/backend/worker/eval.lua Adds eval.dump generator that loads/executes the dump helper via local or target VM mechanisms.
extension/script/backend/worker/breakpoint.lua Reads config.syntaxCompatibility and passes it into the parser; resets on termination.
extension/package.nls.json Adds localized description for the new launch setting.
compile/common/package_json.lua Adds syntaxCompatibility to the generated launch configuration schema.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +45 to +61
generate("dump", function()
if luaver.LUAVERSION <= 52 then
local compat_dump = assert(load(readfile 'backend.worker.eval.dump'))
return function(content)
local res, err = compat_dump(content)
if res then
return true, res
end
return false, err
end
else
local eval_dump = assert(rdebug.load(readfile 'backend.worker.eval.dump'))
return function(content)
return rdebug.eval(eval_dump, content, 0)
end
end
end)
Comment thread extension/script/backend/worker/eval/dump.lua
Comment on lines +108 to 112
if not bin then
local log = require 'common.log'
log.error("ERROR:"..err)
log.error("ERROR:"..(err or "unknown error"))
return
end
Comment thread extension/package.nls.json Outdated
"lua.debug.launch.console.integratedTerminal.description": "VS Code integrated terminal.",
"lua.debug.launch.console.externalTerminal.description": "External terminal that can be configured in user settings.",
"lua.debug.launch.luaVersion.description": "Default lua version.",
"lua.debug.launch.syntaxCompatibility.description": "Use the target Lua VM to parse source syntax for breakpoint line information.",
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.

2 participants