Kaynağa Gözat

LibJS: Fix BindingPattern::contains_expression() is name is expression

If any of binding pattern entry's name is expession
`contains_expression()` should return true.

For example:
```js
function evalInComputedPropertyKey(
  {[eval("var x = 'inner'")]: ignored}
) {}
```

`contains_expression()` should return true for the binding param in
this function.
Aliaksandr Kalenik 1 yıl önce
ebeveyn
işleme
4561469d52
1 değiştirilmiş dosya ile 2 ekleme ve 0 silme
  1. 2 0
      Userland/Libraries/LibJS/AST.cpp

+ 2 - 0
Userland/Libraries/LibJS/AST.cpp

@@ -792,6 +792,8 @@ void NullLiteral::dump(int indent) const
 bool BindingPattern::contains_expression() const
 {
     for (auto& entry : entries) {
+        if (entry.name.has<NonnullRefPtr<Expression const>>())
+            return true;
         if (entry.initializer)
             return true;
         if (auto binding_ptr = entry.alias.get_pointer<NonnullRefPtr<BindingPattern const>>(); binding_ptr && (*binding_ptr)->contains_expression())