-
Notifications
You must be signed in to change notification settings - Fork 81
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
spec: allow record {} <: record {null} #462
Conversation
cc @rossberg |
Benchmark for 84ebd6eClick to view benchmark
|
Benchmark for d44bbcbClick to view benchmark
|
I vaguely remember that we discussed this before, and I believe I was in favor. Maybe someone finds the conversation. |
I couldn't find it on my mobile. So didn't look that hard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (on mobile)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, comments added.
Benchmark for d23c920Click to view benchmark
|
Benchmark for b18531eClick to view benchmark
|
In the current spec, we only allow
record {} <: record {opt t; reserved}
, i.e. users can omitopt
fields orreserved
fields in the argument, but cannot omitnull
fields.In the Rust implementation, however, we accidentally allowed
null
fields to be optional as well. And this bug has become a feature that people start to use it in the wild...The most prominent use is to decode an empty blobDIDL\0\0
into a null value, which corresponds to()
in Rust.This PR tries to make that bug into a feature to allow optional
null
fields in the record.Another option is to make
()
in Rust map to empty message in Candid, and have a dedicatedcandid::Null
type in Rust. But that's also a breaking change.