diff --git a/3rd/bee.lua b/3rd/bee.lua index 466c4f071..f55b6988e 160000 --- a/3rd/bee.lua +++ b/3rd/bee.lua @@ -1 +1 @@ -Subproject commit 466c4f071a17ab7c31e402383b0a2097b03535ba +Subproject commit f55b6988e8d9564816a555118b0e76564ef9a283 diff --git a/3rd/json.lua b/3rd/json.lua index f94860ef5..08095fd2c 160000 --- a/3rd/json.lua +++ b/3rd/json.lua @@ -1 +1 @@ -Subproject commit f94860ef551036490c5b3db6098325267f42ef28 +Subproject commit 08095fd2cdfde8f49a5f5b54b35ec7b3d4906a36 diff --git a/3rd/luamake b/3rd/luamake index d5bd143b0..4c4bd16c9 160000 --- a/3rd/luamake +++ b/3rd/luamake @@ -1 +1 @@ -Subproject commit d5bd143b0307dcb8a7c25fb9308f3f7721fe1a8d +Subproject commit 4c4bd16c9b0c1d773402fc15c76367f7899a1f91 diff --git a/changelog.md b/changelog.md index 79b3e9e02..d4ecb8039 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,11 @@ ## Unreleased +## 3.16.4 +`2025-12-25` +* `FIX` (VSCode) Broken `view document` +* `FIX` `for .. in` should only treat the first variable as const + ## 3.16.3 `2025-12-23` * `CHG` Upgraded to Lua 5.5, memory usage has been reduced by ~10% diff --git a/locale/en-us/meta.lua b/locale/en-us/meta.lua index 756cd1cc5..c0f8edd60 100644 --- a/locale/en-us/meta.lua +++ b/locale/en-us/meta.lua @@ -881,3 +881,5 @@ utf8.len = 'Returns the number of UTF-8 characters in string `s` that start between positions `i` and `j` (both inclusive).' utf8.offset = 'Returns the position (in bytes) where the encoding of the `n`-th character of `s` (counting from position `i`) starts.' +utf8.offset[55] = +'Returns the position of the n-th character of s (counting from byte position i) as two integers: The index (in bytes) where its encoding starts and the index (in bytes) where it ends.' diff --git a/locale/en-us/setting.lua b/locale/en-us/setting.lua index 13f5f9f73..0ba6c2852 100644 --- a/locale/en-us/setting.lua +++ b/locale/en-us/setting.lua @@ -121,8 +121,6 @@ config.diagnostics.validScheme = 'Enable diagnostics for Lua files that use the following scheme.' config.diagnostics.unusedLocalExclude = 'Do not diagnose `unused-local` when the variable name matches the following pattern.' -config.diagnostics.validScheme = -'Enable diagnostics for Lua files that use the following scheme.' config.workspace.ignoreDir = "Ignored files and directories (Use `.gitignore` grammar)."-- .. example.ignoreDir, config.workspace.ignoreSubmodules = diff --git a/locale/es-419/meta.lua b/locale/es-419/meta.lua index 446213a81..d7ef11f08 100644 --- a/locale/es-419/meta.lua +++ b/locale/es-419/meta.lua @@ -880,3 +880,5 @@ utf8.len = 'Retorna el número de caracteres en UTF-8 en el string `s` que empiezan entre las posiciones `i` y `j` (ambos inclusive).' utf8.offset = 'Retorna la posición en bytes donde la codificación del caracter `n`-ésimo de `s` empieza, contado a partir de la posición `i`.' +utf8.offset[55] = +'Retorna la posición del carácter número `n` de `s` (contando desde la posición de byte `i`) como dos enteros: el índice (en bytes) donde empieza su codificación y el índice (en bytes) donde termina.' diff --git a/locale/es-419/setting.lua b/locale/es-419/setting.lua index d29ef2e62..61e8fdbfb 100644 --- a/locale/es-419/setting.lua +++ b/locale/es-419/setting.lua @@ -122,8 +122,6 @@ config.diagnostics.validScheme = 'Habilita diagnósticos para archivos Lua que usan el siguiente esquema.' config.diagnostics.unusedLocalExclude = 'Las variables que calcen con el siguiente patrón no se diagnostican con `unused-local`.' -config.diagnostics.validScheme = -'Habilita diagnósticos para archivos Lua que usan el siguiente esquema.' config.workspace.ignoreDir = "Directorios y archivos ignorados (se usa la misma gramática que en `.gitignore`)" config.workspace.ignoreSubmodules = diff --git a/locale/ja-jp/meta.lua b/locale/ja-jp/meta.lua index 9493b9bcd..d541a9131 100644 --- a/locale/ja-jp/meta.lua +++ b/locale/ja-jp/meta.lua @@ -876,3 +876,5 @@ utf8.len = 'バイト位置 `i` から `j`(両方含む)の間に含まれるUTF-8文字の数を返す。' utf8.offset = '文字列 `s` における `n` 番目の文字が始まるバイト位置をを返す。`i` が指定された場合、`i` から数えたバイト位置を返す。' +utf8.offset[55] = +'文字列 `s` における `n` 番目の文字の位置を、2つの整数として返します(バイト位置 `i` から数えます):その文字のエンコードが開始するバイトインデックスと終了するバイトインデックス。' diff --git a/locale/ja-jp/setting.lua b/locale/ja-jp/setting.lua index 250676365..5bf50c403 100644 --- a/locale/ja-jp/setting.lua +++ b/locale/ja-jp/setting.lua @@ -6,82 +6,129 @@ config.addonManager.repositoryBranch = "アドオンマネージャーが使用するgitブランチを指定します。" config.addonManager.repositoryPath = "アドオンマネージャーが使用するgitパスを指定します。" -config.develop.enable = -'開発者モード。パフォーマンスに影響するため有効にしないでください。' -config.develop.debuggerPort = -'デバッガーの待ち受けポート。' -config.develop.debuggerWait = -'デバッガー接続前に停止します。' -config.intelliSense.searchDepth = -'IntelliSenseの検索深度を設定します。この値を上げると精度が上がりますが、パフォーマンスが低下します。ワークスペースごとに適切な値を調整してください。' -config.intelliSense.fastGlobal = -'グローバル変数補完および `_G` ホバー表示を高速化します。型推論の精度がわずかに低下しますが、多数のグローバルを使うプロジェクトでは大きく改善します。' -config.window.statusBar = -'ステータスバーに拡張機能のステータスを表示します。' -config.window.progressBar = -'ステータスバーに進行状況バーを表示します。' -config.hint.enable = -'インレイヒントを有効にします。' -config.hint.paramType = -'関数のパラメータに型ヒントを表示します。' -config.hint.setType = -'代入操作で型ヒントを表示します。' -config.hint.paramName = -'関数呼び出し時にパラメータ名のヒントを表示します。' -config.hint.paramName.All = -'すべての型のパラメータを表示します。' -config.hint.paramName.Literal = -'リテラル型のパラメータのみを表示します。' -config.hint.paramName.Disable = -'パラメータヒントを無効にします。' -config.hint.arrayIndex = -'テーブル構築時に配列インデックスのヒントを表示します。' -config.hint.arrayIndex.Enable = -'すべてのテーブルでヒントを表示します。' -config.hint.arrayIndex.Auto = -'テーブルが3要素を超える、または混在テーブルの場合のみヒントを表示します。' -config.hint.arrayIndex.Disable = -'配列インデックスのヒントを無効にします。' -config.hint.await = -'呼び出す関数に `---@async` が付いている場合、呼び出し箇所で `await` を提案します。' -config.hint.awaitPropagate = -'`await` の伝播を有効にします。`---@async` が付いた関数を呼び出す関数は、自動的に `---@async` とマークされます。' -config.hint.semicolon = -'文末にセミコロンがない場合に仮想セミコロンを表示します。' -config.hint.semicolon.All = -'すべての文で仮想セミコロンを表示します。' -config.hint.semicolon.SameLine = -'同じ行に2つの文がある場合、その間にセミコロンを表示します。' -config.hint.semicolon.Disable = -'仮想セミコロンを無効にします。' -config.codeLens.enable = -'コードレンズを有効にします。' -config.format.enable = -'コードフォーマッタを有効にします。' -config.format.defaultConfig = +config.addonRepositoryPath = +"アドオンのリポジトリパスを指定します(アドオンマネージャーとは無関係です)。" +config.runtime.version = +"Lua のランタイムバージョン。" +config.runtime.path = [[ -デフォルトのフォーマット設定。ワークスペース内の`.editorconfig`ファイルより優先度が低くなります。 -[formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs) を参照してください。 +`require` を使用する際、入力名に基づいてファイルを探す方法。 +この設定を `?/init.lua` にすると、`require 'myfile'` と入力したとき、読み込まれたファイルから `${workspace}/myfile/init.lua` が検索されます。 +`runtime.pathStrict` が `false` の場合、`${workspace}/**/myfile/init.lua` も検索対象になります。 +ワークスペース外のファイルを読み込みたい場合は、先に `Lua.workspace.library` を設定する必要があります。 ]] -config.spell.dict = -'スペルチェック用のカスタム単語。' -config.nameStyle.config = +config.runtime.pathStrict = +'有効にすると、`runtime.path` は最上位のディレクトリ階層のみを検索します。詳細は `runtime.path` の説明を参照してください。' +config.runtime.special = +[[カスタムのグローバル変数を一部の特別な組み込み変数として扱い、言語サーバーが特別なサポートを提供します。 +以下の例では、`include` を `require` として扱います。 +```json +"Lua.runtime.special" : { + "include" : "require" +} +``` +]] +config.runtime.unicodeName = +"名前に Unicode 文字を使用できるようにします。" +config.runtime.nonstandardSymbol = +"非標準の記号をサポートします。ランタイム環境がこれらの記号をサポートしていることを確認してください。" +config.runtime.plugin = +"プラグインのパス。詳細は [wiki](https://luals.github.io/wiki/plugins) を参照してください。" +config.runtime.pluginArgs = +"プラグインに渡す追加引数。" +config.runtime.fileEncoding = +"ファイルのエンコーディング。`ansi` オプションは `Windows` プラットフォームでのみ利用可能です。" +config.runtime.builtin = [[ -命名スタイル設定。 -[formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs) を参照してください。 +組み込みライブラリの有効状態を調整します。実際のランタイム環境に応じて、存在しないライブラリを無効化(または再定義)できます。 + +* `default`: ランタイムバージョンに応じてライブラリを有効/無効にします +* `enable`: 常に有効 +* `disable`: 常に無効 ]] -config.telemetry.enable = +config.runtime.meta = +'メタファイルのディレクトリ名の形式。' +config.diagnostics.enable = +"診断を有効にします。" +config.diagnostics.disable = +"無効化する診断(ホバーの括弧内に表示されるコードを使用)。" +config.diagnostics.globals = +"定義済みのグローバル変数。" +config.diagnostics.globalsRegex = +"正規表現で定義済みのグローバル変数を検索します。" +config.diagnostics.severity = [[ -テレメトリを有効にし、エディタ情報とエラーログをネットワーク経由で送信します。プライバシーポリシーは[こちら](https://luals.github.io/privacy/#language-server)。 +診断の重大度を変更します。 + +末尾に `!` を付けると、グループ設定 `diagnostics.groupSeverity` を上書きします。 ]] -config.misc.parameters = -'VSCode で言語サーバーを起動するときの[コマンドライン引数](https://github.com/LuaLS/lua-telemetry-server/tree/master/method)。' -config.misc.executablePath = -'VSCodeでの実行可能ファイルのパスを指定します。' -config.language.fixIndent = -'(VSCodeのみ) 誤った自動インデントを修正します。例えば、"function" を含む文字列内で改行したときの不正なインデントなど。' -config.language.completeAnnotation = -'(VSCodeのみ) 注釈行の改行後に自動で "---@ " を挿入します。' +config.diagnostics.neededFileStatus = +[[ +* Opened: 開いているファイルのみを診断 +* Any: すべてのファイルを診断 +* None: この診断を無効化 + +末尾に `!` を付けると、グループ設定 `diagnostics.groupFileStatus` を上書きします。 +]] +config.diagnostics.groupSeverity = +[[ +グループ内の診断の重大度を変更します。 +`Fallback` は、このグループ内の診断が個別に `diagnostics.severity` によって制御されることを意味します。 +その他の設定は、末尾に `!` が付いていない個別の設定を上書きします。 +]] +config.diagnostics.groupFileStatus = +[[ +グループ内の診断対象ファイル状態を変更します。 + +* Opened: 開いているファイルのみを診断 +* Any: すべてのファイルを診断 +* None: この診断を無効化 + +`Fallback` は、このグループ内の診断が個別に `diagnostics.neededFileStatus` によって制御されることを意味します。 +その他の設定は、末尾に `!` が付いていない個別の設定を上書きします。 +]] +config.diagnostics.workspaceEvent = +"ワークスペース診断をトリガーするタイミングを設定します。" +config.diagnostics.workspaceEvent.OnChange = +"ファイルが変更されたときにワークスペース診断をトリガーします。" +config.diagnostics.workspaceEvent.OnSave = +"ファイルが保存されたときにワークスペース診断をトリガーします。" +config.diagnostics.workspaceEvent.None = +"ワークスペース診断を無効にします。" +config.diagnostics.workspaceDelay = +"ワークスペース診断の待ち時間(ミリ秒)。" +config.diagnostics.workspaceRate = +"ワークスペース診断の実行レート(%)。この値を下げると CPU 使用率は低下しますが、ワークスペース診断の速度も低下します。現在編集中のファイルの診断は常に全速で行われ、この設定の影響を受けません。" +config.diagnostics.libraryFiles = +"`Lua.workspace.library` 経由で読み込まれたファイルをどのように診断するか。" +config.diagnostics.libraryFiles.Enable = +"常にこれらのファイルを診断します。" +config.diagnostics.libraryFiles.Opened = +"これらのファイルが開かれているときのみ診断します。" +config.diagnostics.libraryFiles.Disable = +"これらのファイルは診断しません。" +config.diagnostics.ignoredFiles = +"無視されているファイルをどのように診断するか。" +config.diagnostics.ignoredFiles.Enable = +"常にこれらのファイルを診断します。" +config.diagnostics.ignoredFiles.Opened = +"これらのファイルが開かれているときのみ診断します。" +config.diagnostics.ignoredFiles.Disable = +"これらのファイルは診断しません。" +config.diagnostics.disableScheme = +'次のスキームを使用する Lua ファイルは診断しません。' +config.diagnostics.validScheme = +'次のスキームを使用する Lua ファイルの診断を有効にします。' +config.diagnostics.unusedLocalExclude = +'変数名が次のパターンに一致する場合、`unused-local` を診断しません。' +config.workspace.ignoreDir = +"無視するファイルとディレクトリ(`.gitignore` の構文を使用)。"-- .. example.ignoreDir, +config.workspace.ignoreSubmodules = +"サブモジュールを無視します。" +config.workspace.useGitIgnore = +"`.gitignore` に記載されたファイルを無視します。" +config.workspace.maxPreload = +"プリロードする最大ファイル数。" config.workspace.preloadFileSize = "プリロード時にこの値(KB)より大きいファイルをスキップします。" config.workspace.library = @@ -177,6 +224,82 @@ config.hover.expandAlias = [[ エイリアスを展開するかどうか。たとえば、`---@alias myType boolean|number`を展開すると`boolean|number`として表示され、そうでない場合は`myType`として表示されます。 ]] +config.develop.enable = +'開発者モード。パフォーマンスに影響するため有効にしないでください。' +config.develop.debuggerPort = +'デバッガーの待ち受けポート。' +config.develop.debuggerWait = +'デバッガー接続前に停止します。' +config.intelliSense.searchDepth = +'IntelliSenseの検索深度を設定します。この値を上げると精度が上がりますが、パフォーマンスが低下します。ワークスペースごとに適切な値を調整してください。' +config.intelliSense.fastGlobal = +'グローバル変数補完および `_G` ホバー表示を高速化します。型推論の精度がわずかに低下しますが、多数のグローバルを使うプロジェクトでは大きく改善します。' +config.window.statusBar = +'ステータスバーに拡張機能のステータスを表示します。' +config.window.progressBar = +'ステータスバーに進行状況バーを表示します。' +config.hint.enable = +'インレイヒントを有効にします。' +config.hint.paramType = +'関数のパラメータに型ヒントを表示します。' +config.hint.setType = +'代入操作で型ヒントを表示します。' +config.hint.paramName = +'関数呼び出し時にパラメータ名のヒントを表示します。' +config.hint.paramName.All = +'すべての型のパラメータを表示します。' +config.hint.paramName.Literal = +'リテラル型のパラメータのみを表示します。' +config.hint.paramName.Disable = +'パラメータヒントを無効にします。' +config.hint.arrayIndex = +'テーブル構築時に配列インデックスのヒントを表示します。' +config.hint.arrayIndex.Enable = +'すべてのテーブルでヒントを表示します。' +config.hint.arrayIndex.Auto = +'テーブルが3要素を超える、または混在テーブルの場合のみヒントを表示します。' +config.hint.arrayIndex.Disable = +'配列インデックスのヒントを無効にします。' +config.hint.await = +'呼び出す関数に `---@async` が付いている場合、呼び出し箇所で `await` を提案します。' +config.hint.awaitPropagate = +'`await` の伝播を有効にします。`---@async` が付いた関数を呼び出す関数は、自動的に `---@async` とマークされます。' +config.hint.semicolon = +'文末にセミコロンがない場合に仮想セミコロンを表示します。' +config.hint.semicolon.All = +'すべての文で仮想セミコロンを表示します。' +config.hint.semicolon.SameLine = +'同じ行に2つの文がある場合、その間にセミコロンを表示します。' +config.hint.semicolon.Disable = +'仮想セミコロンを無効にします。' +config.codeLens.enable = +'コードレンズを有効にします。' +config.format.enable = +'コードフォーマッタを有効にします。' +config.format.defaultConfig = +[[ +デフォルトのフォーマット設定。ワークスペース内の`.editorconfig`ファイルより優先度が低くなります。 +[formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs) を参照してください。 +]] +config.spell.dict = +'スペルチェック用のカスタム単語。' +config.nameStyle.config = +[[ +命名スタイル設定。 +[formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs) を参照してください。 +]] +config.telemetry.enable = +[[ +テレメトリを有効にし、エディタ情報とエラーログをネットワーク経由で送信します。プライバシーポリシーは[こちら](https://luals.github.io/privacy/#language-server)。 +]] +config.misc.parameters = +'VSCode で言語サーバーを起動するときの[コマンドライン引数](https://github.com/LuaLS/lua-telemetry-server/tree/master/method)。' +config.misc.executablePath = +'VSCodeでの実行可能ファイルのパスを指定します。' +config.language.fixIndent = +'(VSCodeのみ) 誤った自動インデントを修正します。例えば、"function" を含む文字列内で改行したときの不正なインデントなど。' +config.language.completeAnnotation = +'(VSCodeのみ) 注釈行の改行後に自動で "---@ " を挿入します。' config.type.castNumberToInteger = '`number` 型を `integer` 型に代入することを許可します。' config.type.weakUnionCheck = diff --git a/locale/pt-br/meta.lua b/locale/pt-br/meta.lua index 7aa064675..2b0810f41 100644 --- a/locale/pt-br/meta.lua +++ b/locale/pt-br/meta.lua @@ -881,3 +881,5 @@ utf8.len = 'Retorna o número de caracteres UTF-8 na string `s` que começa entre as posições `i` e `j` (ambos inclusos).' utf8.offset = 'Retorna a posição (em bytes) onde a codificação do `n`-ésimo caractere de `s` inícia (contando a partir da posição `i`).' +utf8.offset[55] = +'Retorna a posição do n-ésimo caractere de `s` (contando a partir da posição de byte `i`) como dois inteiros: o índice (em bytes) onde sua codificação começa e o índice (em bytes) onde ela termina.' diff --git a/locale/pt-br/setting.lua b/locale/pt-br/setting.lua index b2777a6b9..b26c4f254 100644 --- a/locale/pt-br/setting.lua +++ b/locale/pt-br/setting.lua @@ -121,8 +121,6 @@ config.diagnostics.validScheme = 'Habilita diagnósticos para arquivos Lua que usam os seguintes schemes.' config.diagnostics.unusedLocalExclude = 'Não diagnosticar `unused-local` quando o nome da variável corresponder ao padrão a seguir.' -config.diagnostics.validScheme = -'Habilita diagnósticos para arquivos Lua que usam os seguintes schemes.' config.workspace.ignoreDir = "Arquivos e diretórios ignorados (usa sintaxe `.gitignore`)."-- .. example.ignoreDir, config.workspace.ignoreSubmodules = diff --git a/locale/zh-cn/meta.lua b/locale/zh-cn/meta.lua index c243434c8..86ae136bb 100644 --- a/locale/zh-cn/meta.lua +++ b/locale/zh-cn/meta.lua @@ -860,3 +860,5 @@ utf8.len = '返回字符串 `s` 中 从位置 `i` 到 `j` 间 (包括两端) UTF-8 字符的个数。' utf8.offset = '返回编码在 `s` 中的第 `n` 个字符的开始位置(按字节数) (从位置 `i` 处开始统计)。' +utf8.offset[55] = +'返回字符串 `s` 中第 `n` 个字符的位置(从字节位置 `i` 开始计数),以两个整数表示:其编码开始的字节索引和结束的字节索引。' diff --git a/locale/zh-cn/setting.lua b/locale/zh-cn/setting.lua index 056867792..cd8f45c40 100644 --- a/locale/zh-cn/setting.lua +++ b/locale/zh-cn/setting.lua @@ -120,8 +120,6 @@ config.diagnostics.validScheme = '对使用以下 scheme 的lua文件启用诊断。' config.diagnostics.unusedLocalExclude = '如果变量名匹配以下规则,则不对其进行 `unused-local` 诊断。' -config.diagnostics.validScheme = -'对使用以下 scheme 的lua文件启用诊断。' config.workspace.ignoreDir = "忽略的文件与目录(使用 `.gitignore` 语法)。" config.workspace.ignoreSubmodules = diff --git a/locale/zh-tw/meta.lua b/locale/zh-tw/meta.lua index b76715457..52169a532 100644 --- a/locale/zh-tw/meta.lua +++ b/locale/zh-tw/meta.lua @@ -864,3 +864,5 @@ utf8.len = '回傳字串 `s` 中 從位置 `i` 到 `j` 間 (包括兩端) UTF-8 字元的個數。' utf8.offset = '回傳編碼在 `s` 中的第 `n` 個字元的開始位置(按位元組數)(從位置 `i` 處開始統計)。' +utf8.offset[55] = +'以兩個整數回傳字串 `s` 中第 `n` 個字元的位置(從位元組位置 `i` 開始計數):其編碼開始的位元組索引與結束的位元組索引。' diff --git a/locale/zh-tw/setting.lua b/locale/zh-tw/setting.lua index de8d79792..15e846bf9 100644 --- a/locale/zh-tw/setting.lua +++ b/locale/zh-tw/setting.lua @@ -120,8 +120,6 @@ config.diagnostics.validScheme = '對使用以下 scheme 的lua檔案啟用診斷。' config.diagnostics.unusedLocalExclude = '如果變數名符合以下規則,則不對其進行 `unused-local` 診斷。' -config.diagnostics.validScheme = -'對使用以下 scheme 的lua檔案啟用診斷。' config.workspace.ignoreDir = "忽略的檔案與目錄(使用 `.gitignore` 語法)。" config.workspace.ignoreSubmodules = diff --git a/meta/template/utf8.lua b/meta/template/utf8.lua index 5c7668384..b47d1b03f 100644 --- a/meta/template/utf8.lua +++ b/meta/template/utf8.lua @@ -67,6 +67,7 @@ function utf8.len(s, i, j) end function utf8.len(s, i, j, lax) end ---#end +---#if VERSION <= 5.4 then ---#DES 'utf8.offset' ---@param s string ---@param n integer @@ -74,5 +75,17 @@ function utf8.len(s, i, j, lax) end ---@return integer p ---@nodiscard function utf8.offset(s, n, i) end +---#end + +---#if VERSION >= 5.5 then +---#DES 'utf8.offset.55' +---@param s string +---@param n integer +---@param i? integer +---@return integer ps +---@return integer pe +---@nodiscard +function utf8.offset(s, n, i) end +---#end return utf8 diff --git a/script/parser/compile.lua b/script/parser/compile.lua index f3b36ba91..d6a8722cc 100644 --- a/script/parser/compile.lua +++ b/script/parser/compile.lua @@ -4098,9 +4098,9 @@ local function parseFor() for i = 1, #list do local obj = list[i] ---@cast obj parser.object - -- In Lua 5.5, for loop variables are treated as constants + -- In Lua 5.5, for first loop variable is treated as constant local attrs - if State.version == 'Lua 5.5' then + if i == 1 and State.version == 'Lua 5.5' then attrs = { type = 'localattrs', start = obj.start, diff --git a/tools/locale.lua b/tools/locale.lua index fa32fe160..537743c52 100644 --- a/tools/locale.lua +++ b/tools/locale.lua @@ -120,6 +120,7 @@ local function buildLocaleFile(localeName, allKeys, localeMap, fileName) local lastKey local blocks = {} local currentBlock = {} + local usedKeys = {} blocks[#blocks+1] = currentBlock for _, key in ipairs(allKeys) do if needSplit(key, lastKey) then @@ -127,7 +128,10 @@ local function buildLocaleFile(localeName, allKeys, localeMap, fileName) blocks[#blocks+1] = currentBlock end lastKey = key - currentBlock[#currentBlock+1] = key + if not usedKeys[key] then + currentBlock[#currentBlock+1] = key + usedKeys[key] = true + end end if fileName == 'meta' then