Skip to content
Snippets Groups Projects
Commit 1e2af7aa authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix crash when parsing function with 'return;'

parent c1c74cfc
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment