mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Provide better way to check compile errors.
Now you can just call `mrb_load_*` functions then check `context->parser_nerr > 0` if the return value is `undef`, instead of calling `mrb_parse_*` functions independently. ref #3248 #3331
This commit is contained in:
@@ -33,6 +33,8 @@ typedef struct mrbc_context {
|
||||
mrb_bool no_exec:1;
|
||||
mrb_bool keep_lv:1;
|
||||
mrb_bool no_optimize:1;
|
||||
|
||||
size_t parser_nerr;
|
||||
} mrbc_context;
|
||||
|
||||
MRB_API mrbc_context* mrbc_context_new(mrb_state *mrb);
|
||||
|
||||
@@ -5777,6 +5777,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
|
||||
return mrb_undef_value();
|
||||
}
|
||||
if (!p->tree || p->nerr) {
|
||||
c->parser_nerr = p->nerr;
|
||||
if (p->capture_errors) {
|
||||
char buf[256];
|
||||
int n;
|
||||
|
||||
Reference in New Issue
Block a user