@@ -123,10 +123,12 @@ pub fn normalize_attribute_types(attributes: &mut Annotated<Attributes>) {
123123 match ( & mut inner. value . ty , & mut inner. value . value ) {
124124 ( Annotated ( Some ( Boolean ) , _) , Annotated ( Some ( Value :: Bool ( _) ) , _) ) => ( ) ,
125125 ( Annotated ( Some ( Integer ) , _) , Annotated ( Some ( Value :: I64 ( _) ) , _) ) => ( ) ,
126- ( Annotated ( Some ( Integer ) , _) , Annotated ( Some ( Value :: U64 ( _) ) , _) ) => {
127- attribute. meta_mut ( ) . add_error ( ErrorKind :: InvalidData ) ;
128- let original = attribute. value_mut ( ) . take ( ) ;
129- attribute. meta_mut ( ) . set_original_value ( original) ;
126+ ( Annotated ( Some ( Integer ) , _) , Annotated ( Some ( Value :: U64 ( u) ) , _) ) => {
127+ if * u > i64:: MAX as u64 {
128+ let original = attribute. value_mut ( ) . take ( ) ;
129+ attribute. meta_mut ( ) . add_error ( ErrorKind :: InvalidData ) ;
130+ attribute. meta_mut ( ) . set_original_value ( original) ;
131+ }
130132 }
131133 ( Annotated ( Some ( Double ) , _) , Annotated ( Some ( Value :: I64 ( _) ) , _) ) => ( ) ,
132134 ( Annotated ( Some ( Double ) , _) , Annotated ( Some ( Value :: U64 ( _) ) , _) ) => ( ) ,
@@ -770,7 +772,7 @@ mod tests {
770772 "type": "integer",
771773 "value": "abc"
772774 },
773- "invalid_int_i64 ": {
775+ "invalid_int ": {
774776 "type": "integer",
775777 "value": 9223372036854775808
776778 },
@@ -815,8 +817,8 @@ mod tests {
815817 "type": "double",
816818 "value": -42
817819 },
820+ "invalid_int": null,
818821 "invalid_int_from_invalid_string": null,
819- "invalid_int_i64": null,
820822 "missing_type": null,
821823 "missing_value": null,
822824 "supported_array_double": {
@@ -876,25 +878,25 @@ mod tests {
876878 "some_other_field": "some_other_value"
877879 },
878880 "_meta": {
879- "invalid_int_from_invalid_string ": {
881+ "invalid_int ": {
880882 "": {
881883 "err": [
882884 "invalid_data"
883885 ],
884886 "val": {
885887 "type": "integer",
886- "value": "abc"
888+ "value": 9223372036854775808
887889 }
888890 }
889891 },
890- "invalid_int_i64 ": {
892+ "invalid_int_from_invalid_string ": {
891893 "": {
892894 "err": [
893895 "invalid_data"
894896 ],
895897 "val": {
896898 "type": "integer",
897- "value": 9223372036854775808
899+ "value": "abc"
898900 }
899901 }
900902 },
0 commit comments