Make mrb_load_exec()
return nil
if there is a syntax error
#5496
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously it returned
undef
.So for example, if there was a syntax error, the following code would cause
SIGSEGV
.This affects the behavior of the
MRB_API
function below:mrb_load_file()
mrb_load_file_cxt()
mrb_load_detect_file_cxt()
mrb_load_string()
mrb_load_nstring()
mrb_load_string_cxt()
mrb_load_nstring_cxt()
I mentioned earlier why I want to change from
undef
tonil
, but here's why I decided to change it:nil
if an error occurred when returning frommrb_top_run()
.mrb->exc
is non-NULL
.mrbc_context::no_exec
is true, it is sufficient to check if it is eitherproc
ornil
.However, this change can cause compatibility issues if it has already used
mrb_undef_p()
to distinguish between syntax errors.This is the reason for making changes to the
mrdb.c
file (although the behavior does not change with or without changes).Just to be sure.
I think the current behavior of returning
undef
is non-bug.