Commit 765ba8a
authored
Fix non-proto3 JSON format double decoding (#1043)
When the field type is a proto `float` or `double` we always use a Dart
`double` for the value. Trying to set the field an `int` causes an assertion
failure in `FieldSet`.
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 an
`int`. So if the value is a string `"1"` it stores as `double` but if it's the
number `1` it tries to convert to double.
This isn't an issue with dart2js as with dart2js `int` and `double` are the
same thing, but it causes assertion failures when this library is used with
dart2wasm which distinguishes `int`s and `double`s.
Fix by always storing proto `float`s and `double`s as Dart `double`s.
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/7999242501 parent 703bf7c commit 765ba8a
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | | - | |
| 392 | + | |
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
| |||
0 commit comments