summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2021-06-26 00:13:47 +0900
committerYusuke Endoh <mame@ruby-lang.org>2021-06-26 00:15:16 +0900
commit68e1dc51720b0f8bb033aac368122dad6c9aa2ed (patch)
treeb102436250c11f3a3af661735943fbcec29fe471 /iseq.c
parent5ffb313ccc5d5a25eb8114332093fbdd20850411 (diff)
iseq.c: Make ast_line_count return 0 when syntax error occurred
This broke coverage CI ``` 1) Failure: TestRequire#test_load_syntax_error [/home/runner/work/actions/actions/ruby/test/ruby/test_require.rb:228]: Exception(SyntaxError) with message matches to /unexpected/. [SyntaxError] exception expected, not #<TypeError: no implicit conversion of false into Integer>. ``` https://github.com/ruby/actions/runs/2914743968?check_suite_focus=true
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/iseq.c b/iseq.c
index 7a3d946edb..9af7b54eff 100644
--- a/iseq.c
+++ b/iseq.c
@@ -816,6 +816,10 @@ rb_iseq_new(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
static int
ast_line_count(const rb_ast_body_t *ast)
{
+ if (ast->script_lines == Qfalse) {
+ // this occurs when failed to parse the source code with a syntax error
+ return 0;
+ }
if (RB_TYPE_P(ast->script_lines, T_ARRAY)){
return (int)RARRAY_LEN(ast->script_lines);
}