jsonnet icon indicating copy to clipboard operation
jsonnet copied to clipboard

enumeration value 'binary' not handled in switch

Open jcpunk opened this issue 2 years ago • 2 comments

Just making sure someone saw this warning

/builddir/build/BUILD/jsonnet-0.19.1/core/vm.cpp:1665:16: warning: enumeration value 'binary' not handled in switch [-Wswitch]
 1665 |         switch (v.type()) {
      |                ^

jcpunk avatar Nov 02 '22 15:11 jcpunk

I think the deal here is if you have a more recent version of that library then there is an additional enum value. There is a PR that fixed it, but I rolled it back because the version in the third_party was older and didn't have it.

sparkprime avatar Nov 02 '22 16:11 sparkprime

"that library" being json.hpp

sparkprime avatar Nov 02 '22 16:11 sparkprime

Since the build is configured to turn on ~all the warnings, IMHO it would be nice to do something about this. Some options:

  1. Disable the warning ¯\_(ツ)_/¯
  2. Upgrade the bundled json.hpp and add a case for binary. This creates the reverse problem that people using a system-provided json library must have a version recent enough to have this enum value. It looks like this was added to nlohmann json in 2019: https://github.com/nlohmann/json/pull/1662 and released in v3.8.0, as of June 2020. For reference, Debian Buster (current supported LTS version) appears to have json v3.5.0: https://packages.debian.org/buster/nlohmann-json3-dev (the next version, Bullseye, has v3.9.1).
  3. #if logic in the switch statement to define a case for value_t::binary only if we're using a json lib version >= 3.8. I would prefer not to do this.
  4. Add a default case and raise an error. This should be both forward and backward compatible.

johnbartholomew avatar Mar 06 '24 11:03 johnbartholomew