diff --git a/crates/engine/src/binding_lists_tests.rs b/crates/engine/src/binding_lists_tests.rs index 8bceafff0..5886a5484 100644 --- a/crates/engine/src/binding_lists_tests.rs +++ b/crates/engine/src/binding_lists_tests.rs @@ -134,12 +134,15 @@ fn a_layer_binds_only_fields_its_effects_have() { let (mut s, r) = setup(); ex(&mut s, "effect.add", json!({"ids": [r], "type": "dropShadow"})); ex(&mut s, "effect.add", json!({"ids": [r], "type": "glass"})); - // As an effect style does: a drop shadow has no refraction, glass no spread, and there is no - // effect 5. Nothing is bound. + // As an effect style does: a drop shadow has no refraction, glass no spread, there is no + // effect 5, and a key that names no effect's field names nothing. Nothing is bound. for (field, var, says) in [ ("effects/0/refraction", "large", "no field"), ("effects/1/spread", "large", "no field"), ("effects/5/radius", "large", "no field"), + ("effects/x/radius", "large", "no field"), + ("effects/0", "large", "no field"), + ("effects", "large", "no field"), ("effects/1/lightAngle", "brand", "doesn't take a color variable"), ("effects/0/color", "large", "doesn't take a number variable"), ] { diff --git a/crates/engine/src/cmd/variables.rs b/crates/engine/src/cmd/variables.rs index 33fb1c973..b6f4d291e 100644 --- a/crates/engine/src/cmd/variables.rs +++ b/crates/engine/src/cmd/variables.rs @@ -661,11 +661,12 @@ fn effect_field(doc: &Document, node: NodeId, i: usize, field: &str) -> Option/` when its effect `i` has that field (a drop shadow has no `refraction`). +/// `effects//` when its effect `i` has that field (a drop shadow has no `refraction`), +/// and an `effects…` key naming no effect's field (`effects/x/radius`, `effects/0`) has none. pub fn has_field(doc: &Document, node: NodeId, field: &str) -> bool { match super::lists::list_binding(field) { Some((BoundList::Effects, i, f)) => effect_field(doc, node, i, f).is_some(), - _ => true, + _ => field.split('/').next() != Some(BoundList::Effects.prefix()), } }