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
d2dd2d0e
Unverified
Commit
d2dd2d0e
authored
Jul 22, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Jul 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4590 from shuujii/fix-Module-dup-to-frozen-module
Fix `Module#dup` to frozen module
parents
477be452
7675fcb5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
src/class.c
src/class.c
+9
-0
src/kernel.c
src/kernel.c
+0
-1
test/t/module.rb
test/t/module.rb
+23
-0
No files found.
src/class.c
View file @
d2dd2d0e
...
...
@@ -2077,6 +2077,14 @@ mrb_mod_eqq(mrb_state *mrb, mrb_value mod)
return
mrb_bool_value
(
eqq
);
}
static
mrb_value
mrb_mod_dup
(
mrb_state
*
mrb
,
mrb_value
self
)
{
mrb_value
mod
=
mrb_obj_clone
(
mrb
,
self
);
MRB_UNSET_FROZEN_FLAG
(
mrb_obj_ptr
(
mod
));
return
mod
;
}
static
mrb_value
mrb_mod_module_function
(
mrb_state
*
mrb
,
mrb_value
mod
)
{
...
...
@@ -2207,6 +2215,7 @@ mrb_init_class(mrb_state *mrb)
mrb_define_method
(
mrb
,
mod
,
"method_defined?"
,
mrb_mod_method_defined
,
MRB_ARGS_REQ
(
1
));
/* 15.2.2.4.34 */
mrb_define_method
(
mrb
,
mod
,
"define_method"
,
mod_define_method
,
MRB_ARGS_ARG
(
1
,
1
));
mrb_define_method
(
mrb
,
mod
,
"==="
,
mrb_mod_eqq
,
MRB_ARGS_REQ
(
1
));
/* 15.2.2.4.7 */
mrb_define_method
(
mrb
,
mod
,
"dup"
,
mrb_mod_dup
,
MRB_ARGS_NONE
());
mrb_undef_method
(
mrb
,
cls
,
"append_features"
);
mrb_undef_method
(
mrb
,
cls
,
"extend_object"
);
...
...
src/kernel.c
View file @
d2dd2d0e
...
...
@@ -805,5 +805,4 @@ mrb_init_kernel(mrb_state *mrb)
mrb_define_method
(
mrb
,
krn
,
"__to_str"
,
mrb_to_str
,
MRB_ARGS_NONE
());
/* internal */
mrb_include_module
(
mrb
,
mrb
->
object_class
,
mrb
->
kernel_module
);
mrb_define_alias
(
mrb
,
mrb
->
module_class
,
"dup"
,
"clone"
);
/* XXX */
}
test/t/module.rb
View file @
d2dd2d0e
...
...
@@ -400,6 +400,29 @@ end
# Not ISO specified
assert
(
'Module#dup'
)
do
module
TestModuleDup
@@cvar
=
:cvar
class
<<
self
attr_accessor
:cattr
def
cmeth
;
:cmeth
end
end
def
cvar
;
@@cvar
end
def
imeth
;
:imeth
end
self
.
cattr
=
:cattr
end
m
=
TestModuleDup
.
dup
o
=
Object
.
include
(
m
).
new
assert_equal
(
:cattr
,
m
.
cattr
)
assert_equal
(
:cmeth
,
m
.
cmeth
)
assert_equal
(
:cvar
,
o
.
cvar
)
assert_equal
(
:imeth
,
o
.
imeth
)
assert_match
(
"#<Module:0x*>"
,
m
.
to_s
)
assert_not_predicate
(
m
,
:frozen?
)
assert_not_predicate
(
TestModuleDup
.
freeze
.
dup
,
:frozen?
)
end
assert
(
'Module#define_method'
)
do
c
=
Class
.
new
{
define_method
(
:m1
)
{
:ok
}
...
...
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