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
a76dc04a
Commit
a76dc04a
authored
Feb 27, 2017
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove default Kernel#method_missing.
Internal method_missing works without problems.
parent
b563bcb7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
31 deletions
+4
-31
src/kernel.c
src/kernel.c
+4
-0
test/t/nomethoderror.rb
test/t/nomethoderror.rb
+0
-31
No files found.
src/kernel.c
View file @
a76dc04a
...
@@ -969,6 +969,7 @@ mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args)
...
@@ -969,6 +969,7 @@ mrb_method_missing(mrb_state *mrb, mrb_sym name, mrb_value self, mrb_value args)
* r.xxiii #=> 23
* r.xxiii #=> 23
* r.mm #=> 2000
* r.mm #=> 2000
*/
*/
#ifndef MRB_DEFAULT_METHOD_MISSING
static
mrb_value
static
mrb_value
mrb_obj_missing
(
mrb_state
*
mrb
,
mrb_value
mod
)
mrb_obj_missing
(
mrb_state
*
mrb
,
mrb_value
mod
)
{
{
...
@@ -981,6 +982,7 @@ mrb_obj_missing(mrb_state *mrb, mrb_value mod)
...
@@ -981,6 +982,7 @@ mrb_obj_missing(mrb_state *mrb, mrb_value mod)
/* not reached */
/* not reached */
return
mrb_nil_value
();
return
mrb_nil_value
();
}
}
#endif
static
inline
mrb_bool
static
inline
mrb_bool
basic_obj_respond_to
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
id
,
int
pub
)
basic_obj_respond_to
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
id
,
int
pub
)
...
@@ -1214,7 +1216,9 @@ mrb_init_kernel(mrb_state *mrb)
...
@@ -1214,7 +1216,9 @@ mrb_init_kernel(mrb_state *mrb)
mrb_define_method
(
mrb
,
krn
,
"iterator?"
,
mrb_f_block_given_p_m
,
MRB_ARGS_NONE
());
/* 15.3.1.3.25 */
mrb_define_method
(
mrb
,
krn
,
"iterator?"
,
mrb_f_block_given_p_m
,
MRB_ARGS_NONE
());
/* 15.3.1.3.25 */
mrb_define_method
(
mrb
,
krn
,
"kind_of?"
,
mrb_obj_is_kind_of_m
,
MRB_ARGS_REQ
(
1
));
/* 15.3.1.3.26 */
mrb_define_method
(
mrb
,
krn
,
"kind_of?"
,
mrb_obj_is_kind_of_m
,
MRB_ARGS_REQ
(
1
));
/* 15.3.1.3.26 */
mrb_define_method
(
mrb
,
krn
,
"local_variables"
,
mrb_local_variables
,
MRB_ARGS_NONE
());
/* 15.3.1.3.28 */
mrb_define_method
(
mrb
,
krn
,
"local_variables"
,
mrb_local_variables
,
MRB_ARGS_NONE
());
/* 15.3.1.3.28 */
#ifndef MRB_DEFAULT_METHOD_MISSING
mrb_define_method
(
mrb
,
krn
,
"method_missing"
,
mrb_obj_missing
,
MRB_ARGS_ANY
());
/* 15.3.1.3.30 */
mrb_define_method
(
mrb
,
krn
,
"method_missing"
,
mrb_obj_missing
,
MRB_ARGS_ANY
());
/* 15.3.1.3.30 */
#endif
mrb_define_method
(
mrb
,
krn
,
"methods"
,
mrb_obj_methods_m
,
MRB_ARGS_OPT
(
1
));
/* 15.3.1.3.31 */
mrb_define_method
(
mrb
,
krn
,
"methods"
,
mrb_obj_methods_m
,
MRB_ARGS_OPT
(
1
));
/* 15.3.1.3.31 */
mrb_define_method
(
mrb
,
krn
,
"nil?"
,
mrb_false
,
MRB_ARGS_NONE
());
/* 15.3.1.3.32 */
mrb_define_method
(
mrb
,
krn
,
"nil?"
,
mrb_false
,
MRB_ARGS_NONE
());
/* 15.3.1.3.32 */
mrb_define_method
(
mrb
,
krn
,
"object_id"
,
mrb_obj_id_m
,
MRB_ARGS_NONE
());
/* 15.3.1.3.33 */
mrb_define_method
(
mrb
,
krn
,
"object_id"
,
mrb_obj_id_m
,
MRB_ARGS_NONE
());
/* 15.3.1.3.33 */
...
...
test/t/nomethoderror.rb
View file @
a76dc04a
...
@@ -21,37 +21,6 @@ assert('NoMethodError#args', '15.2.32.2.1') do
...
@@ -21,37 +21,6 @@ assert('NoMethodError#args', '15.2.32.2.1') do
end
end
end
end
assert
(
'Can still raise when Kernel#method_missing is removed'
)
do
assert_raise
(
NoMethodError
)
do
begin
Kernel
.
alias_method
(
:old_method_missing
,
:method_missing
)
Kernel
.
remove_method
(
:method_missing
)
1
.
__send__
(
:foo
)
ensure
Kernel
.
alias_method
(
:method_missing
,
:old_method_missing
)
Kernel
.
remove_method
(
:old_method_missing
)
end
end
end
assert
(
'Can still call super when Kernel#method_missing is removed'
)
do
assert_raise
(
NoMethodError
)
do
class
A
def
foo
super
end
end
begin
Kernel
.
alias_method
(
:old_method_missing
,
:method_missing
)
Kernel
.
remove_method
(
:method_missing
)
A
.
new
.
foo
ensure
Kernel
.
alias_method
(
:method_missing
,
:old_method_missing
)
Kernel
.
remove_method
(
:old_method_missing
)
end
end
end
assert
(
"NoMethodError#new does not return an exception"
)
do
assert
(
"NoMethodError#new does not return an exception"
)
do
begin
begin
class
<<
NoMethodError
class
<<
NoMethodError
...
...
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