Fix non-proto3 JSON format double decoding #1043
Merged
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.
When the field type is a proto
floatordoublewe always use a Dartdoublefor the value. Trying to set the field anintcauses an assertion failure inFieldSet.This code is also a bit inconsistent in itself: when the jspblite2 value is a string it decodes as
double, but when it's a number it tries to convert to anint. So if the value is a string"1"it stores asdoublebut if it's the number1it tries to convert to double.This isn't an issue with dart2js as with dart2js
intanddoubleare the same thing, but it causes assertion failures when this library is used with dart2wasm which distinguishesints anddoubles.Fix by always storing proto
floats anddoubles as Dartdoubles.Note: this code is currently not used in dart2wasm, instead dart2wasm uses the VM's library. However if I start using this library instead (for benchmarking, to potentially switch to this library) then it breaks. So currently this change is not a user-visible change because dart2wasm doesn't use this library.
cl/799924250