Permalink
Browse files

Fixed a problem where splatted nil would get converted to [nil].

Fixes #2926.

Previously, the JIT code was not checking for nil, when trying to cast
the stack value to an array, thus creating an array with just nil in it.
This fix ensures an empty array gets created instead.

With help from @dbussink, and recorded it live on an hangout!
  • Loading branch information...
1 parent b7e379b commit e1b064cd6b91e3ca1afcae27ff70ebc34226cdf1 @razielgn razielgn committed Feb 11, 2014
Showing with 3 additions and 1 deletion.
  1. +3 −1 vm/llvm/jit_util.cpp
View
@@ -306,7 +306,9 @@ extern "C" {
}
Object* rbx_cast_array(STATE, CallFrame* call_frame, Object* top) {
- if(Tuple* tup = try_as<Tuple>(top)) {
+ if(top->nil_p()) {
+ return Array::create_dirty(state, 0);
+ } else if(Tuple* tup = try_as<Tuple>(top)) {
return Array::from_tuple(state, tup);
} else if(kind_of<Array>(top)) {
return top;

0 comments on commit e1b064c

Please sign in to comment.