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
5efe77fe
Commit
5efe77fe
authored
Mar 30, 2017
by
Kouichi Nakanishi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify class variable definition in singleton class; fix #3539
parent
898077a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
src/variable.c
src/variable.c
+14
-4
test/t/class.rb
test/t/class.rb
+13
-0
No files found.
src/variable.c
View file @
5efe77fe
...
@@ -819,12 +819,22 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)
...
@@ -819,12 +819,22 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v)
c
=
c
->
super
;
c
=
c
->
super
;
}
}
if
(
!
cls
->
iv
)
{
if
(
cls
&&
cls
->
tt
==
MRB_TT_SCLASS
)
{
cls
->
iv
=
iv_new
(
mrb
);
mrb_value
klass
;
klass
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
cls
,
mrb_intern_lit
(
mrb
,
"__attached__"
));
c
=
mrb_class_ptr
(
klass
);
}
else
{
c
=
cls
;
}
if
(
!
c
->
iv
)
{
c
->
iv
=
iv_new
(
mrb
);
}
}
mrb_write_barrier
(
mrb
,
(
struct
RBasic
*
)
c
ls
);
mrb_write_barrier
(
mrb
,
(
struct
RBasic
*
)
c
);
iv_put
(
mrb
,
c
ls
->
iv
,
sym
,
v
);
iv_put
(
mrb
,
c
->
iv
,
sym
,
v
);
}
}
MRB_API
void
MRB_API
void
...
...
test/t/class.rb
View file @
5efe77fe
...
@@ -384,6 +384,19 @@ assert('class variable and class << self style class method') do
...
@@ -384,6 +384,19 @@ assert('class variable and class << self style class method') do
assert_equal
(
"value"
,
ClassVariableTest
.
class_variable
)
assert_equal
(
"value"
,
ClassVariableTest
.
class_variable
)
end
end
assert
(
'class variable definition in singleton_class'
)
do
class
ClassVariableDefinitionInSingletonTest
class
<<
self
@@class_variable
=
"value"
end
def
class_variable
@@class_variable
end
end
assert_equal
(
"value"
,
ClassVariableDefinitionInSingletonTest
.
new
.
class_variable
)
end
assert
(
'class variable in module and class << self style class method'
)
do
assert
(
'class variable in module and class << self style class method'
)
do
module
ClassVariableInModuleTest
module
ClassVariableInModuleTest
@@class_variable
=
"value"
@@class_variable
=
"value"
...
...
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