[macruby-changes] [1308] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 3 16:47:49 PDT 2009
Revision: 1308
http://trac.macosforge.org/projects/ruby/changeset/1308
Author: lsansonetti at apple.com
Date: 2009-04-03 16:47:48 -0700 (Fri, 03 Apr 2009)
Log Message:
-----------
the return value of a class/module expression is the return value of the body, and not the class/module itself
Modified Paths:
--------------
MacRuby/branches/experimental/roxor.cpp
MacRuby/branches/experimental/vm-tests/class.rb
MacRuby/branches/experimental/vm-tests/module.rb
Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp 2009-04-03 23:41:02 UTC (rev 1307)
+++ MacRuby/branches/experimental/roxor.cpp 2009-04-03 23:47:48 UTC (rev 1308)
@@ -3298,7 +3298,7 @@
std::map<ID, int *> old_ivar_slots_cache = ivar_slots_cache;
ivar_slots_cache.clear();
- compile_node(body->nd_body);
+ Value *val = compile_node(body->nd_body);
BasicBlock::InstListType &list = bb->getInstList();
compile_ivar_slots(classVal, list, list.end());
@@ -3307,10 +3307,12 @@
current_opened_class = old_class;
ivar_slots_cache = old_ivar_slots_cache;
+
+ return val;
}
}
- return classVal;
+ return nilVal;
}
break;
Modified: MacRuby/branches/experimental/vm-tests/class.rb
===================================================================
--- MacRuby/branches/experimental/vm-tests/class.rb 2009-04-03 23:41:02 UTC (rev 1307)
+++ MacRuby/branches/experimental/vm-tests/class.rb 2009-04-03 23:47:48 UTC (rev 1308)
@@ -25,3 +25,6 @@
end
p X.foo
}
+
+assert "42", "x = class Foo; 42; end; p x"
+assert "nil", "x = class Foo; end; p x"
Modified: MacRuby/branches/experimental/vm-tests/module.rb
===================================================================
--- MacRuby/branches/experimental/vm-tests/module.rb 2009-04-03 23:41:02 UTC (rev 1307)
+++ MacRuby/branches/experimental/vm-tests/module.rb 2009-04-03 23:47:48 UTC (rev 1308)
@@ -1,2 +1,5 @@
assert "M", "module M; end; p M"
assert "Module", "module M; end; p M.class"
+
+assert "42", "x = module Foo; 42; end; p x"
+assert "nil", "x = module Foo; end; p x"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090403/9f65a0ca/attachment.html>
More information about the macruby-changes
mailing list