FSharp.Data icon indicating copy to clipboard operation
FSharp.Data copied to clipboard

Numeric inference in 3.0.0 appears broken

Open panesofglass opened this issue 7 years ago • 4 comments

In FSharp.Data 3.0.0-beta4, inference for a JSON with a numeric array field worked properly. When attempting to upgrade to 3.0.0, however, the inference breaks, and the inferred type is int []. I'm currently working on a repro test case. This is preventing our ability to update to the 3.0.0 release version.

panesofglass avatar Oct 23 '18 13:10 panesofglass

I suspect this commit may be the culprit, but I'm still looking: https://github.com/fsharp/FSharp.Data/commit/8d05e4bf32fe750cb0f1bad977cbd5b97b39ab17

panesofglass avatar Oct 23 '18 14:10 panesofglass

What does your numeric array field look like? After bumping to v3.0, 0.1e1 is inferred as int. To fix it I had to change to 0.1e0 or 0.11e1.

For arrays, make sure all the entries are in exponential format. Maybe that helps.

atlemann avatar Jan 10 '19 14:01 atlemann

I'm figuring out ways to work around this, but I think the general inference should be that, if there's an e or E in the string representation, it should be a float.

panesofglass avatar Jan 15 '19 20:01 panesofglass

I think we could solve this with some additional information attached to the JsonValue.Float case that let us know if the float value was exponential or not. Then we could use that flag to disallow inferring the sample value as an integer at all.

baronfel avatar Jan 15 '19 21:01 baronfel