Yukihiro "Matz" Matsumoto
b43c146455
Check ensure proc is NULL before calling; fix #3943
2018-02-09 12:34:54 +09:00
Takeshi Watanabe
3c18ec27e9
Fix possible memory access error.
2018-02-02 13:30:32 +09:00
Yukihiro "Matz" Matsumoto
55431b4cef
Need not to pop callinfo on OP_STOP.
2018-01-30 22:55:58 +09:00
Yukihiro "Matz" Matsumoto
d895861a30
Check arena_idx before accessing; fix #3934
2018-01-25 12:30:10 +09:00
Yukihiro "Matz" Matsumoto
e5fb21b6d2
Detect cyclic link of class path references; fix #3926
2018-01-17 09:41:26 +09:00
Yukihiro "Matz" Matsumoto
3ae621fcb3
Typo fixed.
2018-01-17 09:38:41 +09:00
Yukihiro "Matz" Matsumoto
6999e45742
Do not include object string representation in NoMethodError message.
...
This information is not mandatory but causes a lot of problems in the
past due to infinite recursion by redefining `to_str`, `inspect` etc.
2017-12-23 15:15:03 +09:00
Yukihiro "Matz" Matsumoto
ca0f32a208
super should raise TypeError when the receiver is switched; fix #3911
...
The receiver can be switched using `#instance_eval` etc.
2017-12-23 11:14:12 +09:00
Yukihiro "Matz" Matsumoto
7e520838b3
Avoid infinite recursion in method_missing; ref #3908
2017-12-23 11:13:27 +09:00
Yukihiro "Matz" Matsumoto
44b4f69fce
May need more stack space in mrb_funcall_with_block; fix #3908
2017-12-23 10:01:30 +09:00
Yukihiro "Matz" Matsumoto
7fbbd7ab9f
Should not overwrite ci->target_class in mrb_exec_irep().
...
For example, the following code behaved wrong:
```ruby
Object.instance_exec(1,2,3){|*a|
def foo
42
end
}
p foo()
```
2017-12-23 10:01:30 +09:00
Lothar Scholz
06f90a3b45
Make source compilable with C++17
...
Changes applied:
- Removing "register" keyword
- Fixing const pointer to pointer assignments
- Adding type casts to rb_malloc calls
2017-12-23 01:10:43 +01:00
Yukihiro "Matz" Matsumoto
100f0e6759
Do not need to take target_class from the upper proc.
...
Since it is already set in `mrb_proc_new()`.
2017-12-20 19:37:26 +09:00
Yukihiro "Matz" Matsumoto
73b05f0130
Should not overwrite MRB_PROC_TARGET_CLASS(p) if p has env; fix #3905
2017-12-20 19:37:26 +09:00
Yukihiro "Matz" Matsumoto
165e7b181b
Fixed method look-up for method_missing in OP_SUPER; ref #3905
...
Method look-up for `OP_SUPER` should start from the superclass of
the `target_class` but if it fails, the look-up for `method_missing`
should start from the class of the receiver.
The following code explains the case:
```ruby
class Bar
def foo
super
end
end
class Foo<Bar
def method_missing(mid, *)
p mid
end
end
```
Foo.new.foo
2017-12-20 19:37:26 +09:00
Yukihiro "Matz" Matsumoto
d0f60182af
The superclass info should be taken from `TARGET_CLASS(ci->proc).
...
Not from `ci->target_class` that may be switched using `class_eval` etc.
fix #3899 , fix #3906
We found out there is a mruby specific limitation that `super` may be
screwed up when a method is defined in a module and `super` is called
in the block with the target class switched (for example, `super` in
`class_eval` block). Now we raise `RuntimeError` for such cases.
The following code works in CRuby but not in mruby.
```
module M
def foo
"aaa".singleton_class.class_eval{super 2}
end
end
class Foo
def foo(*); end
end
class Bar<Foo
include M
end
Bar.new.foo
```
2017-12-20 10:34:54 +09:00
Yukihiro "Matz" Matsumoto
ddb1aae41d
Need to set ci->proc before calling methods; fix #3902
2017-12-16 09:33:37 +09:00
Yukihiro "Matz" Matsumoto
03614ed918
Need to clear exception handler on return; fix #3898
2017-12-16 09:17:07 +09:00
Yukihiro "Matz" Matsumoto
05129ab9b3
Check if destinations are too distant; fix #3900 fix #3901
2017-12-15 17:57:45 +09:00
Yukihiro "Matz" Matsumoto
11b6696ce2
Retrieve operands at the beginning of OP_SCLASS.
2017-12-13 08:43:15 +09:00
Yukihiro "Matz" Matsumoto
ad06781107
Fixed wrong MRB_WITHOUT_FLOAT condition; ref #3827
2017-12-13 08:38:34 +09:00
Yukihiro "Matz" Matsumoto
bbb0882343
Modifying frozen objects will raise FrozenError.
...
`FrozenError` is a subclass of `RuntimeError` which used to be
raised. [Ruby2.5]
2017-12-12 18:41:18 +09:00
Yukihiro "Matz" Matsumoto
10ed730e4b
Cancel df3507660 that does not do any good.
2017-12-07 15:18:41 +09:00
Yukihiro "Matz" Matsumoto
cdf173d32c
Avoid updating to reallocated stack in OP_RETURN; fix #3870
...
The code was introduced to address #3175 but it's no longer needed.
2017-12-07 15:05:14 +09:00
Yukihiro "Matz" Matsumoto
0e46b14b9e
The ci should not be equal to cibase with OP_R_BREAK; #3871
2017-12-06 17:28:20 +09:00
Yukihiro "Matz" Matsumoto
6975258efd
The proc with top-level env must be 'proc-closure'; fix #3871
2017-12-06 17:28:20 +09:00
Yukihiro "Matz" Matsumoto
ae44e80668
Limit ecall() depth to 32 (default).
2017-12-06 17:28:20 +09:00
Yukihiro "Matz" Matsumoto
b00d45b095
mrb_method_search_vm() should gives the defined class.
...
Otherwise `super` may call a wrong method.
2017-12-06 17:28:20 +09:00
Yukihiro "Matz" Matsumoto
4a99f4949e
Need to set ci->proc when we have RProc structure.
...
Mentioned in https://qiita.com/bamchoh/items/eabebbbb330cb0e0470a
2017-12-05 11:43:12 +09:00
Yukihiro "Matz" Matsumoto
0b5d97ec42
Need to unshare env stack on break; fix #3866
2017-12-04 10:15:12 +09:00
Yukihiro "Matz" Matsumoto
6f4d4bbcc7
Remove temporary objects from GC arena in `mrb_vformat()'; #3863
2017-12-04 08:56:11 +09:00
Yukihiro "Matz" Matsumoto
5d04e3316b
Check if ci->proc is not NULL and MRB_PROC_CFUNC_P(); fix #3867
2017-12-04 08:56:11 +09:00
Yukihiro "Matz" Matsumoto
cd9f53d42e
Pop exception objects from the bottom of GC arena; fix #3863
2017-12-04 08:56:11 +09:00
Yukihiro "Matz" Matsumoto
c35a402676
The stack shift width should be determined by p->upper; fix #3864
...
And check required register number from `ci->proc` as well.
The fixes for #3859 and #3862 were incomplete.
2017-12-01 10:01:46 +09:00
Yukihiro "Matz" Matsumoto
86ef9a2806
Avoid calling mrb_env_unshare() when env is NULL.
...
Small performance improvement by reducing function invocations.
2017-11-30 08:19:38 +09:00
Yukihiro "Matz" Matsumoto
2b9f762ba1
Avoid double free() of env stack; fix #3860
...
Should turn on `MRB_ENV_STACK_UNSHARED` flag only after env stack
reallocation. `malloc()` may fail.
2017-11-30 08:17:14 +09:00
Yukihiro "Matz" Matsumoto
d3e273ba4e
Wrong stack adjustment in ecall() ( f35f975 #3859 ); fix #3862
2017-11-30 08:04:27 +09:00
Yukihiro "Matz" Matsumoto
f3279b41e6
Stop infinite recursion in Class#to_s; fix #3861
2017-11-30 07:58:11 +09:00
Yukihiro "Matz" Matsumoto
5f7cdecdc9
Clear c->prev on fiber termination.
2017-11-29 20:25:55 +09:00
Yukihiro "Matz" Matsumoto
b746a0f0d2
Need to free contexts when freeing fibers.
...
Memory leak fixed; ref #3711
2017-11-29 20:24:03 +09:00
Yukihiro "Matz" Matsumoto
9c78a9bfa2
Set MRB_FIBER_TERMINATED flag on exception termination of a fiber.
2017-11-29 20:17:33 +09:00
Yukihiro "Matz" Matsumoto
b7c3a876f1
Add most recent call last message to the backtrace.
2017-11-29 16:56:10 +09:00
Yukihiro "Matz" Matsumoto
3e67a116d1
Call all ensure clauses pushed at OP_STOP.
2017-11-29 12:16:16 +09:00
Yukihiro "Matz" Matsumoto
afa53809e2
No need to use ecall_adjust().
2017-11-29 12:15:24 +09:00
Yukihiro "Matz" Matsumoto
f35f975d26
Fixed stack address adjustment in ecall(); fix #3859
2017-11-29 12:14:05 +09:00
Yukihiro "Matz" Matsumoto
d4fc980527
Need to evaluate ensure clauses at fiber termination.
2017-11-29 11:57:33 +09:00
Yukihiro "Matz" Matsumoto
6bb5ad786c
Remove unnecessary code; ref #3711
2017-11-29 11:44:07 +09:00
Yukihiro "Matz" Matsumoto
284a1d12ee
Provide shortcut comparison methods for numbers for performance.
2017-11-22 15:43:48 +09:00
Yukihiro "Matz" Matsumoto
0ab21a9a5e
Stack adjustment should be based on p->upper; fix #3857
...
It used to be based on `ci->proc` but the callinfo position may be
wrong when `ecall()` is called during stack rewinding from `OP_RETURN`.
2017-11-22 14:05:11 +09:00
Yukihiro "Matz" Matsumoto
fbafa78098
Clear ensure stack after calling in OP_EPOP; #3855 3856
2017-11-22 12:22:45 +09:00