fix(vm): raise a clear error when encoding a decoded table - #421
Open
SAY-5 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
davydog187
reviewed
Aug 23, 2026
Comment on lines
+298
to
+301
| "cannot encode a list of {key, value} pairs into a Lua value. This is the " <> | ||
| "shape `decode/2` produces for a table, and it does not round-trip back " <> | ||
| "into the VM. Convert it to a map first (e.g. `Map.new/1`), which encodes " <> | ||
| "as a Lua table." |
Contributor
There was a problem hiding this comment.
let's use a heredoc here?
davydog187
approved these changes
Aug 23, 2026
davydog187
left a comment
Contributor
There was a problem hiding this comment.
Looks great! just one nitpick on the error message string construction
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.
Closes #408.
Value.encode/3had no clause for a list of{key, value}pairs, which is exactly the shapedecode/2produces for a table. Passing a decoded table straight back intoset!/3fell into the positional-list branch and crashed with a bareFunctionClauseError(each pair is a 2-tuple matching noencodeclause).This adds a branch that refuses that shape with a clear message pointing at
Map.new/1, mirroring the existing struct and cyclic-tref refusals. Behavior for keyword lists and plain sequences is unchanged.