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
d7a34b62
Commit
d7a34b62
authored
Dec 19, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1611 from h2so5/inspect-type
fix TypeError message
parents
c514b369
38a0a604
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
src/object.c
src/object.c
+14
-2
No files found.
src/object.c
View file @
d7a34b62
...
...
@@ -292,6 +292,17 @@ mrb_init_object(mrb_state *mrb)
mrb_define_method
(
mrb
,
f
,
"inspect"
,
false_to_s
,
MRB_ARGS_NONE
());
}
static
mrb_value
inspect_type
(
mrb_state
*
mrb
,
mrb_value
val
)
{
if
(
mrb_type
(
val
)
==
MRB_TT_FALSE
||
mrb_type
(
val
)
==
MRB_TT_TRUE
)
{
return
mrb_inspect
(
mrb
,
val
);
}
else
{
return
mrb_str_new_cstr
(
mrb
,
mrb_obj_classname
(
mrb
,
val
));
}
}
static
mrb_value
convert_type
(
mrb_state
*
mrb
,
mrb_value
val
,
const
char
*
tname
,
const
char
*
method
,
int
raise
)
{
...
...
@@ -300,7 +311,7 @@ convert_type(mrb_state *mrb, mrb_value val, const char *tname, const char *metho
m
=
mrb_intern_cstr
(
mrb
,
method
);
if
(
!
mrb_respond_to
(
mrb
,
val
,
m
))
{
if
(
raise
)
{
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"can't convert %S into %S"
,
val
,
mrb_str_new_cstr
(
mrb
,
tname
));
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"can't convert %S into %S"
,
inspect_type
(
mrb
,
val
)
,
mrb_str_new_cstr
(
mrb
,
tname
));
return
mrb_nil_value
();
}
else
{
...
...
@@ -499,8 +510,9 @@ mrb_to_integer(mrb_state *mrb, mrb_value val, const char *method)
if
(
mrb_fixnum_p
(
val
))
return
val
;
v
=
convert_type
(
mrb
,
val
,
"Integer"
,
method
,
TRUE
);
if
(
!
mrb_obj_is_kind_of
(
mrb
,
v
,
mrb
->
fixnum_class
))
{
mrb_value
type
=
inspect_type
(
mrb
,
val
);
mrb_raisef
(
mrb
,
E_TYPE_ERROR
,
"can't convert %S to Integer (%S#%S gives %S)"
,
val
,
val
,
mrb_str_new_cstr
(
mrb
,
method
),
v
);
type
,
type
,
mrb_str_new_cstr
(
mrb
,
method
),
inspect_type
(
mrb
,
v
)
);
}
return
v
;
}
...
...
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