brandonchinn178 / aeson-schemas

Easily consume JSON data on-demand with type-safety
http://hackage.haskell.org/package/aeson-schemas
BSD 3-Clause "New" or "Revised" License
52 stars 1 forks source link

Check incompatible phantom schemas #53

Open brandon-leapyear opened 3 years ago

brandon-leapyear commented 3 years ago

The following schemas compile, but would always fail at runtime:

[schema| { a: Int, [b]: { a: Bool } } |]
[schema| { a: Int, [b]: { [c]: { a: Bool } } } |]

This is because phantom keys are parsed from the parent object, which means that FromJSON will attempt to parse { a: Int } and { a: Bool } from the same object. In other words, these schemas will never successfully parse.

Unsure how important this is; would love to see an example of someone running afoul of this, and how long it took to debug.