Skip to content

Commit

Permalink
patterns: Fix default coercion error on transition_dep
Browse files Browse the repository at this point in the history
Summary: From previous diff

Reviewed By: IanChilds

Differential Revision: D69713862

fbshipit-source-id: 742a2afa171313172fc5258a12a434d54904809e
  • Loading branch information
JakobDegen authored and facebook-github-bot committed Feb 23, 2025
1 parent 7d4cd43 commit 6df4740
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
30 changes: 10 additions & 20 deletions app/buck2_interpreter_for_build/src/attrs/attrs_global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,11 @@ fn attr_module(registry: &mut GlobalsBuilder) {

let coerced_default = match default {
None => None,
Some(default) => {
match coercer.coerce(
AttrIsConfigurable::Yes,
&attr_coercion_context_for_bzl(eval)?,
default,
) {
Ok(coerced_default) => Some(coerced_default),
Err(_) => return Err(ValueError::IncorrectParameterType.into()),
}
}
Some(default) => Some(coercer.coerce(
AttrIsConfigurable::Yes,
&attr_coercion_context_for_bzl(eval)?,
default,
)?),
};

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

let coerced_default = match default {
None => None,
Some(default) => {
match coercer.coerce(
AttrIsConfigurable::Yes,
&attr_coercion_context_for_bzl(eval)?,
default,
) {
Ok(coerced_default) => Some(coerced_default),
Err(_) => return Err(ValueError::IncorrectParameterType.into()),
}
}
Some(default) => Some(coercer.coerce(
AttrIsConfigurable::Yes,
&attr_coercion_context_for_bzl(eval)?,
default,
)?),
};

Ok(StarlarkAttribute::new(Attribute::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ Caused by:
2: Traceback (most recent call last):
* error_rule.bzl:22, in <module>
"someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transiti...
error: Type of parameters mismatch

error: Error coercing "notaproperlabel"
--> error_rule.bzl:22:21
|
22 | "someattr": attrs.transition_dep(default = "notaproperlabel", cfg = _transition),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|

3: Invalid target pattern `notaproperlabel` is not allowed
4: Expected a `:`, a trailing `/...` or the literal `...`.

0 comments on commit 6df4740

Please sign in to comment.