Description
Please signal an error when a field's default value isn't permitted; that is when it doesn't match the field type. In particular, when the type is a union, please signal an error if the default isn't a permitted value of the first schema in the union.
For example, these field declarations are erroneous:
{"name":"f1", "type":["null", "int"], "default": 3} {"name":"f2", "type":["int", "null"], "default": null}In the current Java implementation, schema resolution using these schemata will result in f1=null (not 3) and f2=0 (not null). This quiet choice of an unintended value is apt to cause trouble that's difficult to diagnose.
I propose that schema parsing signal an error when attempting to parse such an erroneous schema. Another option is for schema resolution to signal an error when the reader's schema is erroneous. Schema parsing is better, I think, since it will help catch mistakes earlier, when they're cheaper to correct. It wouldn't hurt for both schema parsing and resolution to check.