Skip to content

Commit

Permalink
Remove error_buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Apr 24, 2024
1 parent cbc9afa commit 76412cc
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,8 @@ struct parser_params {
unsigned int do_split: 1;
unsigned int error_tolerant: 1;
unsigned int keep_tokens: 1;
unsigned int main_context: 1;

/* TODO: Remove error_buffer */
VALUE error_buffer;
rb_parser_errors_t errors;
rb_parser_ary_t *debug_lines;
/*
Expand Down Expand Up @@ -7773,8 +7772,8 @@ yycompile0(VALUE arg)
p->lex.strterm = 0;
p->lex.pcur = p->lex.pbeg = p->lex.pend = 0;
if (n || p->error_p) {
VALUE exc = p->error_buffer;
if (!exc) {
VALUE exc;
if (p->main_context) {
exc = syntax_error_new();
}
else {
Expand Down Expand Up @@ -15819,7 +15818,6 @@ parser_initialize(struct parser_params *p)
p->delayed.token = NULL;
p->frozen_string_literal = -1; /* not specified */
#ifndef RIPPER
p->error_buffer = Qfalse;
/* TODO: Set errors.path ? */
p->errors.errors = rb_parser_ary_new_capa_for_error(p, 10);
p->end_expect_token_locations = NULL;
Expand Down Expand Up @@ -15851,9 +15849,7 @@ rb_ruby_parser_mark(void *ptr)

rb_gc_mark(p->ruby_sourcefile_string);
rb_gc_mark((VALUE)p->ast);
#ifndef RIPPER
rb_gc_mark(p->error_buffer);
#else
#ifdef RIPPER
rb_gc_mark(p->value);
rb_gc_mark(p->result);
rb_gc_mark(p->parsing_thread);
Expand Down Expand Up @@ -15974,7 +15970,7 @@ rb_ruby_parser_new(void)
rb_parser_t *
rb_ruby_parser_set_context(rb_parser_t *p, const struct rb_iseq_struct *base, int main)
{
p->error_buffer = main ? Qfalse : Qnil;
p->main_context = main;
p->parent_iseq = base;
return p;
}
Expand Down Expand Up @@ -16238,13 +16234,13 @@ parser_compile_error(struct parser_params *p, const rb_code_location_t *loc, con
rb_io_flush(p->debug_output);
p->error_p = 1;
va_start(ap, fmt);
if (!p->error_buffer) {
rb_syntax_error_append(p->error_buffer,
if (p->main_context) {
rb_syntax_error_append(Qfalse,
p->ruby_sourcefile_string,
lineno, column,
p->enc, fmt, ap);
if (lastline) {
ruby_show_error_line(p, p->error_buffer, Qnil, loc, lineno, lastline);
ruby_show_error_line(p, Qfalse, Qnil, loc, lineno, lastline);
}
}
else {
Expand Down

0 comments on commit 76412cc

Please sign in to comment.