🩹 [Patch]: Reserved words in Lua input now detected with option to skip validation#6
Draft
Marius Storhaug (MariusStorhaug) wants to merge 3 commits intomainfrom
Draft
🩹 [Patch]: Reserved words in Lua input now detected with option to skip validation#6Marius Storhaug (MariusStorhaug) wants to merge 3 commits intomainfrom
Marius Storhaug (MariusStorhaug) wants to merge 3 commits intomainfrom
Conversation
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
…e error message for reserved words in Read-LuaTable
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ConvertFrom-Luanow validates that bare identifier keys and variable names are not Lua reserved words, throwing a clear error by default. A new-SkipValidationswitch allows lenient import of out-of-spec data, emitting per-occurrence warnings instead. Enum string serialization no longer double-escapes backslashes.Changed: Reserved word validation on deserialization
ConvertFrom-Luanow rejects bare reserved words used as table keys or assignment variable names — matching the Lua 5.4 §3.1 grammar rules. Previously, invalid Lua like{ end = 1 }orwhile = 42was silently parsed.Bracket-notation keys with reserved word strings remain fully supported:
New:
-SkipValidationswitch for lenient importWhen importing data that may not be spec-compliant, use
-SkipValidationto suppress errors. Each reserved word occurrence produces its own warning, and parsing continues normally.Fixed: Enum string escaping no longer double-escapes backslashes
ConvertTo-Lua -EnumsAsStringspreviously produced\\\\instead of\\for backslashes in enum string representations due to an incorrect-replacepattern.Technical Details
ConvertFrom-Lua.ps1: Added-SkipValidationswitch parameter, threaded toConvertFrom-LuaTablevia-SkipValidation:$SkipValidation.ConvertFrom-LuaTable.ps1: Added-SkipValidationparameter. Stored as$script:luaSkipValidationfor use by recursive parser functions. Added$reservedWordsarray and validation after variable name extraction in the assignment parsing path — throws or warns based on skip flag.Read-LuaTable.ps1: Added$reservedWordsarray and validation after bare identifier +=detection — throws or warns based on$script:luaSkipValidation.ConvertTo-LuaTable.ps1: Fixed enum escaping:-replace '\\', '\\\\'→-replace '\\', '\\'.returnkeyword note:returnis consumed as a leading keyword before assignment detection (forreturn { ... }patterns), soreturn = 42triggers a different parse error rather than the reserved word check. Tests usewhileas the second assignment variable test word.-SkipValidation(bare key warning, assignment warning, multiple warnings with count assertion)."