Skip to content

Instantly share code, notes, and snippets.

@headius
Created January 10, 2014 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/8360925 to your computer and use it in GitHub Desktop.
Save headius/8360925 to your computer and use it in GitHub Desktop.
diff --git a/core/src/main/java/org/jruby/internal/runtime/methods/MethodNodes.java b/core/src/main/java/org/jruby/internal/runtime/methods/MethodNodes.java
index b3af109..3d6c358 100644
--- a/core/src/main/java/org/jruby/internal/runtime/methods/MethodNodes.java
+++ b/core/src/main/java/org/jruby/internal/runtime/methods/MethodNodes.java
@@ -19,6 +19,7 @@ public class MethodNodes {
public MethodNodes(ArgsNode argsNode, Node bodyNode) {
assert argsNode != null;
+ assert bodyNode != null;
this.argsNode = argsNode;
this.bodyNode = bodyNode;
diff --git a/core/src/main/java/org/jruby/parser/Ruby20Parser.java b/core/src/main/java/org/jruby/parser/Ruby20Parser.java
index 8a1eb97..658b6d8 100644
--- a/core/src/main/java/org/jruby/parser/Ruby20Parser.java
+++ b/core/src/main/java/org/jruby/parser/Ruby20Parser.java
@@ -4587,8 +4587,8 @@ states[64] = new ParserState() {
};
states[326] = new ParserState() {
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) {
- /* TODO: We should use implicit nil for body, but problem (punt til later)*/
- Node body = ((Node)yyVals[-1+yyTop]); /*$5 == null ? NilImplicitNode.NIL : $5;*/
+ Node body = ((Node)yyVals[-1+yyTop]);
+ if (body == null) body = NilImplicitNode.NIL;
yyVal = new DefnNode(((Token)yyVals[-5+yyTop]).getPosition(), new ArgumentNode(((Token)yyVals[-4+yyTop]).getPosition(), (String) ((Token)yyVals[-4+yyTop]).getValue()), ((ArgsNode)yyVals[-2+yyTop]), support.getCurrentScope(), body);
support.popCurrentScope();
diff --git a/core/src/main/java/org/jruby/parser/Ruby20Parser.y b/core/src/main/java/org/jruby/parser/Ruby20Parser.y
index 77f6c87..fc52bbe 100644
--- a/core/src/main/java/org/jruby/parser/Ruby20Parser.y
+++ b/core/src/main/java/org/jruby/parser/Ruby20Parser.y
@@ -1249,8 +1249,8 @@ primary : literal
support.setInDef(true);
support.pushLocalScope();
} f_arglist bodystmt kEND {
- // TODO: We should use implicit nil for body, but problem (punt til later)
- Node body = $5; //$5 == null ? NilImplicitNode.NIL : $5;
+ Node body = $5;
+ if (body == null) body = NilImplicitNode.NIL;
$$ = new DefnNode($1.getPosition(), new ArgumentNode($2.getPosition(), (String) $2.getValue()), $4, support.getCurrentScope(), body);
support.popCurrentScope();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment