diff --git a/lib/coffee_script/grammar.y b/lib/coffee_script/grammar.y index 8b459ee8..ea3845ee 100644 --- a/lib/coffee_script/grammar.y +++ b/lib/coffee_script/grammar.y @@ -38,7 +38,8 @@ prechigh right THROW FOR NEW SUPER left EXTENDS left ASSIGN '||=' '&&=' - right RETURN '=>' UNLESS IF ELSE WHILE + right RETURN + right '=>' UNLESS IF ELSE WHILE preclow rule @@ -124,6 +125,7 @@ rule # A return statement. Return: RETURN Expression { result = ReturnNode.new(val[1]) } + | RETURN { result = ReturnNode.new(ValueNode.new(Value.new('null'))) } ; # A comment. diff --git a/test/fixtures/execution/test_literals.coffee b/test/fixtures/execution/test_literals.coffee index 27fec2d3..6570509e 100644 --- a/test/fixtures/execution/test_literals.coffee +++ b/test/fixtures/execution/test_literals.coffee @@ -11,4 +11,10 @@ print(!!words.match(regex)) neg: (3 -4) -print(neg is -1) \ No newline at end of file +print(neg is -1) + + +func: => + return if true + +print(func() is null) \ No newline at end of file