Skip to content

Commit 5b20343

Browse files
committed
fix on eval with not exsisting file.
`eval` can specify unexisting file so it shouldn't read. Without `eval` the file can be removed just after compiling, the error should not be propagated. If given file is existing file for eval context, it should not override the source code. The issue is pointed at #10 by casperisfine and this patc contains a part of his patch.
1 parent 1f28e19 commit 5b20343

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/debug/source_repository.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ def add iseq, src
99
path = '-e' if iseq.path == '-e'
1010

1111
case
12+
when src
13+
if File.file?(path)
14+
path = '(eval)' + path
15+
src = nil
16+
end
1217
when path = iseq.absolute_path
13-
src = File.read(path)
18+
begin
19+
src = File.read(path)
20+
rescue SystemCallError
21+
end
1422
when iseq.path == '-e'
1523
path = '-e'
1624
else

0 commit comments

Comments
 (0)