summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDaniel Bovensiepen <[email protected]>2012-11-22 16:14:54 +0800
committerDaniel Bovensiepen <[email protected]>2012-11-22 16:14:54 +0800
commitc794d1c46b968a3bcbf0eaef0a2df4038dffaf61 (patch)
tree9ad3df86bc354897c9dbcc664db95b9552f4e37e
parent953cbff65c322eac30b6a766eac2676e9eb67ac6 (diff)
parent276b77021fb099b1b767d5a606ef709fafd7421b (diff)
downloadmruby-c794d1c46b968a3bcbf0eaef0a2df4038dffaf61.tar.gz
mruby-c794d1c46b968a3bcbf0eaef0a2df4038dffaf61.zip
Merge remote-tracking branch 'upstream/master' into mrbgems
-rw-r--r--src/vm.c20
-rw-r--r--test/t/float.rb2
2 files changed, 18 insertions, 4 deletions
diff --git a/src/vm.c b/src/vm.c
index ebd505366..61274e374 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -151,14 +151,27 @@ uvset(mrb_state *mrb, int up, int idx, mrb_value v)
mrb_write_barrier(mrb, (struct RBasic*)e);
}
+static inline int
+is_strict(mrb_state *mrb, struct REnv *e)
+{
+ int cioff = e->cioff;
+
+ if (cioff >= 0 && mrb->cibase[cioff].proc &&
+ MRB_PROC_STRICT_P(mrb->cibase[cioff].proc)) {
+ return 1;
+ }
+ return 0;
+}
+
struct REnv*
-top_env(struct RProc *proc)
+top_env(mrb_state *mrb, struct RProc *proc)
{
struct REnv *e = proc->env;
+ if (is_strict(mrb, e)) return e;
while (e->c) {
- if (!e) return 0;
e = (struct REnv*)e->c;
+ if (is_strict(mrb, e)) return e;
}
return e;
}
@@ -1165,8 +1178,9 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
break;
case OP_R_RETURN:
if (!proc->env) goto NORMAL_RETURN;
+ if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;
else {
- struct REnv *e = top_env(proc);
+ struct REnv *e = top_env(mrb, proc);
if (e->cioff < 0) {
localjump_error(mrb, "return");
diff --git a/test/t/float.rb b/test/t/float.rb
index e2c139c03..abb5cf2e7 100644
--- a/test/t/float.rb
+++ b/test/t/float.rb
@@ -105,7 +105,7 @@ assert('Float#round', '15.2.9.3.12') do
i = 3.423456789.round(3)
a == 3 and b == 4 and c == 3 and d == -3 and e == -4 and
- f == 12350 and g == 3 and h == 3.4 and i == 3.423
+ f == 12350 and g == 3 and check_float(h, 3.4) and check_float(i, 3.423)
end
assert('Float#to_f', '15.2.9.3.13') do