Maps behave in a very interesting way if they are set to be implicit-presence fields. They present the possibility that the key or value (or both) can be the default zero value. When that happens, access to the key or the value is unaffected. In this case, presence is a bit of a meaningless concept. Zero keys are valid as map indices, and if a map entry is set to zero, it just always exists. Reflection is a little weird too. - If you do reflection on a normal integer field and ask if a zero-valued field exists, it will tell you that it doesn't exist. This is consistent with what "implicit presence" means. - If you do reflection on a zero integer field that happens to be a map key, it will tell you that it exists. Fetching the value of map[0] is equally valid. (Note that this is not exactly *intended*, but it's just hard to change... and this implementation results in simpler gencode.) I'm adding unit tests in no_field_presence_test to cover this quirk. PiperOrigin-RevId: 676268392pull/18359/head
parent
921b71958d
commit
27ee74e6c6
3 changed files with 991 additions and 7 deletions
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue