Commit 835da83c authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2456 from take-cheeze/refactor_eval

Refactor eval.
parents 42110dce dfe65423
......@@ -112,11 +112,14 @@ create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, cha
if (file) {
mrbc_filename(mrb, cxt, file);
}
cxt->capture_errors = TRUE;
p = mrb_parser_new(mrb);
p->s = s;
p->send = s + len;
mrb_parser_parse(p, cxt);
p = mrb_parse_nstring(mrb, s, len, cxt);
/* only occur when memory ran out */
if (!p) {
mrb_raise(mrb, E_RUNTIME_ERROR, "Failed to create parser state.");
}
if (0 < p->nerr) {
/* parse error */
......
......@@ -44,3 +44,9 @@ assert('rest arguments of eval') do
Kernel.eval('[\'test\', __FILE__, __LINE__]', nil, 'test.rb', 10)
end
end
assert 'eval syntax error' do
assert_raise(SyntaxError) do
eval 'p "test'
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment