fix: remove incorrect dynamic attr check
This commit is contained in:
@@ -529,16 +529,21 @@ where
|
||||
binding_keys.push(alias_sym);
|
||||
}
|
||||
|
||||
let (required, optional) = params
|
||||
.iter()
|
||||
.partition_map(|Param { sym, sym_span, default, .. }| {
|
||||
let (required, optional) = params.iter().partition_map(
|
||||
|Param {
|
||||
sym,
|
||||
sym_span,
|
||||
default,
|
||||
..
|
||||
}| {
|
||||
use itertools::Either::*;
|
||||
if default.is_none() {
|
||||
Left((*sym, *sym_span))
|
||||
} else {
|
||||
Right((*sym, *sym_span))
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
let slots: Vec<_> = ctx.reserve_slots(binding_keys.len()).collect();
|
||||
let let_bindings: HashMap<_, _> = binding_keys
|
||||
@@ -790,9 +795,6 @@ fn finalize_pending_value<Ctx: DowngradeContext, const ALLOW_DYN: bool>(
|
||||
) -> Result<ExprId> {
|
||||
match value {
|
||||
PendingValue::Expr(expr) => {
|
||||
if !ALLOW_DYN {
|
||||
check_no_dynamic_attrs(&expr, ctx)?;
|
||||
}
|
||||
let id = Downgrade::downgrade(expr, ctx)?;
|
||||
Ok(ctx.maybe_thunk(id))
|
||||
}
|
||||
@@ -830,24 +832,3 @@ fn finalize_pending_value<Ctx: DowngradeContext, const ALLOW_DYN: bool>(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check that an expression doesn't contain dynamic attributes (for let bindings).
|
||||
fn check_no_dynamic_attrs(expr: &ast::Expr, ctx: &impl DowngradeContext) -> Result<()> {
|
||||
let ast::Expr::AttrSet(attrset) = expr else {
|
||||
return Ok(());
|
||||
};
|
||||
for v in attrset.attrpath_values() {
|
||||
v.attrpath().unwrap().attrs().try_for_each(|attr| {
|
||||
if let ast::Attr::Dynamic(dyn_attr) = attr {
|
||||
Err(Error::downgrade_error(
|
||||
"dynamic attributes not allowed in let bindings".to_string(),
|
||||
ctx.get_current_source(),
|
||||
dyn_attr.syntax().text_range(),
|
||||
))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user