Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
b09d2eb9
Commit
b09d2eb9
authored
Jul 23, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kernel#instance_eval should define singleton methods; fix #4069
parent
cb42c987
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
mrbgems/mruby-eval/src/eval.c
mrbgems/mruby-eval/src/eval.c
+1
-0
mrbgems/mruby-eval/test/eval.rb
mrbgems/mruby-eval/test/eval.rb
+16
-1
No files found.
mrbgems/mruby-eval/src/eval.c
View file @
b09d2eb9
...
...
@@ -325,6 +325,7 @@ f_instance_eval(mrb_state *mrb, mrb_value self)
proc
=
create_proc_from_string
(
mrb
,
s
,
len
,
mrb_nil_value
(),
file
,
line
);
MRB_PROC_SET_TARGET_CLASS
(
proc
,
mrb_class_ptr
(
cv
));
mrb_assert
(
!
MRB_PROC_CFUNC_P
(
proc
));
mrb
->
c
->
ci
->
target_class
=
mrb_class_ptr
(
cv
);
return
exec_irep
(
mrb
,
self
,
proc
);
}
else
{
...
...
mrbgems/mruby-eval/test/eval.rb
View file @
b09d2eb9
...
...
@@ -100,7 +100,22 @@ assert('Object#instance_eval with begin-rescue-ensure execution order') do
assert_equal
([
:enter_raise_hell
,
:begin
,
:rescue
,
:ensure
],
hell_raiser
.
raise_hell
)
end
assert
(
'Kernel.#eval(strinng) Issue #4021'
)
do
assert
(
'Kernel#instance_eval() to define singleton methods Issue #3141'
)
do
foo_class
=
Class
.
new
do
def
bar
(
x
)
instance_eval
"def baz;
#{
x
}
; end"
end
end
f1
=
foo_class
.
new
f2
=
foo_class
.
new
f1
.
bar
1
f2
.
bar
2
assert_equal
(
1
){
f1
.
baz
}
assert_equal
(
2
){
f2
.
baz
}
end
assert
(
'Kernel.#eval(string) Issue #4021'
)
do
assert_equal
(
'FOO'
)
{
(
eval
<<
'EOS'
).
call
}
foo = "FOO"
Proc.new { foo }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment