mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
compile.c: compile error than rb_bug [ci skip]
* compile.c (get_local_var_idx, get_dyna_var_idx): raise a compile error which is useful than rb_bug, when ID is not found. * compile.c (iseq_set_sequence): ditto when IC index overflow, with dumping generated code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
96c26fbba3
commit
dcfb7f6d54
1 changed files with 11 additions and 4 deletions
15
compile.c
15
compile.c
|
@ -370,7 +370,7 @@ NORETURN(static void append_compile_error(rb_iseq_t *iseq, int line, const char
|
|||
#endif
|
||||
|
||||
static void
|
||||
append_compile_error(rb_iseq_t *iseq, int line, const char *fmt, ...)
|
||||
append_compile_error(const rb_iseq_t *iseq, int line, const char *fmt, ...)
|
||||
{
|
||||
VALUE err_info = ISEQ_COMPILE_DATA(iseq)->err_info;
|
||||
VALUE file = rb_iseq_path(iseq);
|
||||
|
@ -567,6 +567,8 @@ APPEND_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *const anchor, LINK_ELEMENT *before, LI
|
|||
#define APPEND_ELEM(anchor, before, elem) APPEND_ELEM(iseq, (anchor), (before), (elem))
|
||||
#endif
|
||||
|
||||
#define ISEQ_LAST_LINE(iseq) (ISEQ_COMPILE_DATA(iseq)->last_line)
|
||||
|
||||
static int
|
||||
iseq_add_mark_object_compile_time(const rb_iseq_t *iseq, VALUE v)
|
||||
{
|
||||
|
@ -1393,7 +1395,8 @@ get_local_var_idx(const rb_iseq_t *iseq, ID id)
|
|||
int idx = get_dyna_var_idx_at_raw(iseq->body->local_iseq, id);
|
||||
|
||||
if (idx < 0) {
|
||||
rb_bug("get_local_var_idx: %d", idx);
|
||||
COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq),
|
||||
"get_local_var_idx: %d", idx);
|
||||
}
|
||||
|
||||
return idx;
|
||||
|
@ -1414,7 +1417,8 @@ get_dyna_var_idx(const rb_iseq_t *iseq, ID id, int *level, int *ls)
|
|||
}
|
||||
|
||||
if (idx < 0) {
|
||||
rb_bug("get_dyna_var_idx: -1");
|
||||
COMPILE_ERROR(iseq, ISEQ_LAST_LINE(iseq),
|
||||
"get_dyna_var_idx: -1");
|
||||
}
|
||||
|
||||
*level = lv;
|
||||
|
@ -2154,7 +2158,10 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
|
|||
unsigned int ic_index = FIX2UINT(operands[j]);
|
||||
IC ic = (IC)&body->is_entries[ic_index];
|
||||
if (UNLIKELY(ic_index >= body->is_size)) {
|
||||
rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, body->is_size);
|
||||
BADINSN_DUMP(anchor, &iobj->link, 0);
|
||||
COMPILE_ERROR(iseq, iobj->insn_info.line_no,
|
||||
"iseq_set_sequence: ic_index overflow: index: %d, size: %d",
|
||||
ic_index, body->is_size);
|
||||
}
|
||||
generated_iseq[code_index + 1 + j] = (VALUE)ic;
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue