@@ -160,10 +160,7 @@ create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, con
160
160
cxt = mrbc_context_new (mrb );
161
161
cxt -> lineno = line ;
162
162
163
- if (!file ) {
164
- file = "(eval)" ;
165
- }
166
- mrbc_filename (mrb , cxt , file );
163
+ mrbc_filename (mrb , cxt , file ? file : "(eval)" );
167
164
cxt -> capture_errors = TRUE;
168
165
cxt -> no_optimize = TRUE;
169
166
@@ -178,9 +175,17 @@ create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, con
178
175
/* parse error */
179
176
mrb_value str ;
180
177
181
- str = mrb_format (mrb , "line %S: %S" ,
182
- mrb_fixnum_value (p -> error_buffer [0 ].lineno ),
183
- mrb_str_new_cstr (mrb , p -> error_buffer [0 ].message ));
178
+ if (file ) {
179
+ str = mrb_format (mrb , " file %S line %S: %S" ,
180
+ mrb_str_new_cstr (mrb , file ),
181
+ mrb_fixnum_value (p -> error_buffer [0 ].lineno ),
182
+ mrb_str_new_cstr (mrb , p -> error_buffer [0 ].message ));
183
+ }
184
+ else {
185
+ str = mrb_format (mrb , " line %S: %S" ,
186
+ mrb_fixnum_value (p -> error_buffer [0 ].lineno ),
187
+ mrb_str_new_cstr (mrb , p -> error_buffer [0 ].message ));
188
+ }
184
189
mrb_parser_free (p );
185
190
mrbc_context_free (mrb , cxt );
186
191
mrb_exc_raise (mrb , mrb_exc_new_str (mrb , E_SYNTAX_ERROR , str ));
0 commit comments