Skip to content
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

fix(stdlib): Ensure consistent marshal representation #2045

Merged
merged 4 commits into from Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/test/stdlib/marshal.test.gr
Expand Up @@ -91,3 +91,5 @@ let truncatedRecord = Bytes.slice(
)
)
assert Result.isErr(unmarshal(truncatedRecord))

assert Marshal.marshal("🌾") == Marshal.marshal("🌾")
5 changes: 4 additions & 1 deletion stdlib/marshal.gr
Expand Up @@ -423,8 +423,11 @@ let marshal = (value, buf) => {
@unsafe
provide let marshal = value => {
let valuePtr = fromGrain(value)
let buf = allocateBytes(size(valuePtr))
let size = size(valuePtr)
let buf = allocateBytes(size)
Memory.fill(buf + 8n, 0n, size)
phated marked this conversation as resolved.
Show resolved Hide resolved
marshal(valuePtr, buf + 8n)
ignore(value)
toGrain(buf): Bytes
}

Expand Down