Commit 1e2af7aa authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix crash when parsing function with 'return;'

parent c1c74cfc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ module JsDuck
    end

    def return_this?(ast)
      return?(ast) && this?(ast["argument"])
      return?(ast) && !!ast["argument"] && this?(ast["argument"])
    end

    def return?(ast)
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,10 @@ describe "JsDuck::FunctionAst#chainable?" do
    chainable?("/** */ function foo() {}").should == false
  end

  it "false when body has empty return statement" do
    chainable?("/** */ function foo() { return; }").should == false
  end

  it "true when single RETURN THIS statement in body" do
    chainable?("/** */ function foo() {return this;}").should == true
  end