Skip to content

Commit 238448c

Browse files
fix: Emit reference for rescued bindings. (#83)
1 parent 06b3f4d commit 238448c

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

scip_indexer/SCIPIndexer.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static bool isTemporary(const core::GlobalState &gs, const core::LocalVariable &
111111
auto n = var._name;
112112
return n == Names::blockPreCallTemp() || n == Names::blockTemp() || n == Names::blockPassTemp() ||
113113
n == Names::blkArg() || n == Names::blockCall() || n == Names::blockBreakAssign() || n == Names::forTemp() ||
114+
n == Names::keepForCfgTemp() ||
114115
// Insert checks because sometimes temporaries are initialized with a 0 unique value. 😬
115116
n == Names::finalReturn() || n == NameRef::noName() || n == Names::blockCall() || n == Names::selfLocal() ||
116117
n == Names::unconditional();

test/scip/testdata/rescue.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# typed: true
2+
3+
class MyError < StandardError
4+
end
5+
6+
def handle(e)
7+
puts e.inspect.to_s
8+
end
9+
10+
def f
11+
begin
12+
raise 'This exception will be rescued!'
13+
rescue MyError => e1
14+
handle(e1)
15+
rescue StandardError => e2
16+
handle(e2)
17+
end
18+
end

test/scip/testdata/rescue.snapshot.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# typed: true
2+
3+
class MyError < StandardError
4+
# ^^^^^^^ definition [..] MyError#
5+
# ^^^^^^^^^^^^^ definition [..] StandardError#
6+
end
7+
8+
def handle(e)
9+
#^^^^^^^^^^^^^ definition [..] Object#handle().
10+
# ^ definition local 1~#780127187
11+
puts e.inspect.to_s
12+
# ^ reference local 1~#780127187
13+
end
14+
15+
def f
16+
#^^^^^ definition [..] Object#f().
17+
begin
18+
raise 'This exception will be rescued!'
19+
rescue MyError => e1
20+
# ^^^^^^^ reference local 1~#3809224601
21+
# ^^^^^^^ reference [..] MyError#
22+
# ^^ definition local 1~#3809224601
23+
handle(e1)
24+
# ^^^^^^ reference [..] Object#handle().
25+
# ^^ reference local 1~#3809224601
26+
rescue StandardError => e2
27+
# ^^^^^^^^^^^^^ reference local 2~#3809224601
28+
# ^^^^^^^^^^^^^ reference [..] StandardError#
29+
# ^^ definition local 2~#3809224601
30+
handle(e2)
31+
# ^^^^^^ reference [..] Object#handle().
32+
# ^^ reference local 2~#3809224601
33+
end
34+
end

0 commit comments

Comments
 (0)