Skip to content

Commit c6ce433

Browse files
take-cheezematz
authored andcommitted
Add SyntaxError test and don't print compilation error to stderr in eval.
1 parent d1eea45 commit c6ce433

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

mrbgems/mruby-eval/src/eval.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, cha
112112
if (file) {
113113
mrbc_filename(mrb, cxt, file);
114114
}
115+
cxt->capture_errors = TRUE;
115116

116117
p = mrb_parse_nstring(mrb, s, len, cxt);
117118

mrbgems/mruby-eval/test/eval.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@
4444
Kernel.eval('[\'test\', __FILE__, __LINE__]', nil, 'test.rb', 10)
4545
end
4646
end
47+
48+
assert 'eval syntax error' do
49+
assert_raise(SyntaxError) do
50+
eval 'p "test'
51+
end
52+
end

0 commit comments

Comments
 (0)