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
ad492eb9
Commit
ad492eb9
authored
Jan 11, 2016
by
Kouhei Sutou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix class variable reference in module
Fix #3079
parent
e132de9e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
src/variable.c
src/variable.c
+1
-1
test/t/class.rb
test/t/class.rb
+13
-0
No files found.
src/variable.c
View file @
ad492eb9
...
@@ -773,7 +773,7 @@ mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
...
@@ -773,7 +773,7 @@ mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym)
klass
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
cls
,
klass
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
cls
,
mrb_intern_lit
(
mrb
,
"__attached__"
));
mrb_intern_lit
(
mrb
,
"__attached__"
));
c
=
mrb_class_ptr
(
klass
);
c
=
mrb_class_ptr
(
klass
);
if
(
c
->
tt
==
MRB_TT_CLASS
)
{
if
(
c
->
tt
==
MRB_TT_CLASS
||
c
->
tt
==
MRB_TT_MODULE
)
{
while
(
c
)
{
while
(
c
)
{
if
(
c
->
iv
&&
iv_get
(
mrb
,
c
->
iv
,
sym
,
&
v
))
{
if
(
c
->
iv
&&
iv_get
(
mrb
,
c
->
iv
,
sym
,
&
v
))
{
return
v
;
return
v
;
...
...
test/t/class.rb
View file @
ad492eb9
...
@@ -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 in module and class << self style class method'
)
do
module
ClassVariableInModuleTest
@@class_variable
=
"value"
class
<<
self
def
class_variable
@@class_variable
end
end
end
assert_equal
(
"value"
,
ClassVariableInModuleTest
.
class_variable
)
end
assert
(
'class with non-class/module outer raises TypeError'
)
do
assert
(
'class with non-class/module outer raises TypeError'
)
do
assert_raise
(
TypeError
)
{
class
0::C1
;
end
}
assert_raise
(
TypeError
)
{
class
0::C1
;
end
}
assert_raise
(
TypeError
)
{
class
[]
::
C2
;
end
}
assert_raise
(
TypeError
)
{
class
[]
::
C2
;
end
}
...
...
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