Skip to content

Commit 044a986

Browse files
committed
feat: indicate type for field conflicts
1 parent 6d48b4b commit 044a986

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/parser_util.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ where
4848
target_fields.push(field);
4949
return Ok(());
5050
};
51-
51+
5252
can_fields_merge(&matching_field, &field, type_name, field_map)?;
5353

5454
field.position = field.position.min(matching_field.position);
@@ -80,14 +80,14 @@ where
8080
return Err(format!(
8181
"Unknown field '{}' on type '{}'",
8282
field_a.name.as_ref(),
83-
&type_name
83+
type_name
8484
));
8585
};
8686
let Some(_field_b) = field_map.get(field_b.name.as_ref()) else {
8787
return Err(format!(
8888
"Unknown field '{}' on type '{}'",
8989
field_b.name.as_ref(),
90-
&type_name
90+
type_name
9191
));
9292
};
9393

@@ -100,8 +100,9 @@ where
100100

101101
if field_a.name != field_b.name {
102102
return Err(format!(
103-
"Fields '{}' conflict because '{}' and '{}' are different fields",
103+
"Fields '{}' on type '{}' conflict because '{}' and '{}' are different fields",
104104
alias_or_name(field_a),
105+
type_name,
105106
field_a.name.as_ref(),
106107
field_b.name.as_ref(),
107108
));
@@ -121,8 +122,9 @@ where
121122
};
122123
if !args_match {
123124
return Err(format!(
124-
"Fields '{}' conflict because they have differing arguments",
125+
"Fields '{}' on type '{}' conflict because they have differing arguments",
125126
alias_or_name(field_a),
127+
type_name,
126128
));
127129
}
128130
}
@@ -147,8 +149,9 @@ pub fn has_same_type_shape(
147149
type_b = nullable_type_b.type_.as_ref();
148150
} else {
149151
return Err(format!(
150-
"Fields '{}' conflict because only one is non nullable",
152+
"Fields '{}' on type '{}' conflict because only one is non nullable",
151153
field_name,
154+
type_name,
152155
));
153156
}
154157
}
@@ -159,8 +162,9 @@ pub fn has_same_type_shape(
159162
type_b = list_type_b.type_.as_ref();
160163
} else {
161164
return Err(format!(
162-
"Fields '{}' conflict because only one is a list type",
165+
"Fields '{}' on type '{}' conflict because only one is a list type",
163166
field_name,
167+
type_name,
164168
));
165169
}
166170

@@ -176,8 +180,9 @@ pub fn has_same_type_shape(
176180
Ok(())
177181
} else {
178182
Err(format!(
179-
"Fields '{}' conflict due to mismatched types",
183+
"Fields '{}' on type '{}' conflict due to mismatched types",
180184
field_name,
185+
type_name,
181186
))
182187
};
183188
}

0 commit comments

Comments
 (0)