adding empty return statements -- they return null

This commit is contained in:
Jeremy Ashkenas
2010-01-06 21:21:42 -05:00
parent 41bb6edcd2
commit fbcdc12a9c
2 changed files with 10 additions and 2 deletions

View File

@@ -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.

View File

@@ -11,4 +11,10 @@ print(!!words.match(regex))
neg: (3 -4)
print(neg is -1)
print(neg is -1)
func: =>
return if true
print(func() is null)