Commit 9aac3c91 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix adapting of ForInStatement.

When for-in contains variable declaration, Esprima produced the
whole VariableDeclaration, but RKelly gives just VarDeclNode -
so we wrap it inside a VariabelDeclaration to match Esprima output.
parent 9007d945
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -278,7 +278,16 @@ module JsDuck
        when RKelly::Nodes::ForInNode == node.class
          make(node, {
            "type" => "ForInStatement",
            "left" => adapt_node(node.left),
            "left" =>
              if node.left.class == RKelly::Nodes::VarDeclNode
                make(node.left, {
                    "type" => "VariableDeclaration",
                    "kind" => "var",
                    "declarations" => [adapt_node(node.left)]
                  })
              else
                adapt_node(node.left)
              end,
            "right" => adapt_node(node.right),
            "body" => adapt_node(node.value),
            "each" => false,