Skip to content

Commit 6df4740

Browse files
JakobDegenfacebook-github-bot
authored andcommitted
patterns: Fix default coercion error on transition_dep
Summary: From previous diff Reviewed By: IanChilds Differential Revision: D69713862 fbshipit-source-id: 742a2afa171313172fc5258a12a434d54904809e
1 parent 7d4cd43 commit 6df4740

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

app/buck2_interpreter_for_build/src/attrs/attrs_global.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,11 @@ fn attr_module(registry: &mut GlobalsBuilder) {
217217

218218
let coerced_default = match default {
219219
None => None,
220-
Some(default) => {
221-
match coercer.coerce(
222-
AttrIsConfigurable::Yes,
223-
&attr_coercion_context_for_bzl(eval)?,
224-
default,
225-
) {
226-
Ok(coerced_default) => Some(coerced_default),
227-
Err(_) => return Err(ValueError::IncorrectParameterType.into()),
228-
}
229-
}
220+
Some(default) => Some(coercer.coerce(
221+
AttrIsConfigurable::Yes,
222+
&attr_coercion_context_for_bzl(eval)?,
223+
default,
224+
)?),
230225
};
231226

232227
Ok(StarlarkAttribute::new(Attribute::new(
@@ -262,16 +257,11 @@ fn attr_module(registry: &mut GlobalsBuilder) {
262257

263258
let coerced_default = match default {
264259
None => None,
265-
Some(default) => {
266-
match coercer.coerce(
267-
AttrIsConfigurable::Yes,
268-
&attr_coercion_context_for_bzl(eval)?,
269-
default,
270-
) {
271-
Ok(coerced_default) => Some(coerced_default),
272-
Err(_) => return Err(ValueError::IncorrectParameterType.into()),
273-
}
274-
}
260+
Some(default) => Some(coercer.coerce(
261+
AttrIsConfigurable::Yes,
262+
&attr_coercion_context_for_bzl(eval)?,
263+
default,
264+
)?),
275265
};
276266

277267
Ok(StarlarkAttribute::new(Attribute::new(

tests/core/interpreter/test_attr_default_coercion_data/golden/default_not_a_label.golden.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ Caused by:
1212
2: Traceback (most recent call last):
1313
* error_rule.bzl:22, in <module>
1414
"someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transiti...
15-
error: Type of parameters mismatch
15+
16+
error: Error coercing "notaproperlabel"
1617
--> error_rule.bzl:22:21
1718
|
1819
22 | "someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transition),
1920
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2021
|
21-
22+
3: Invalid target pattern `notaproperlabel` is not allowed
23+
4: Expected a `:`, a trailing `/...` or the literal `...`.

0 commit comments

Comments
 (0)