Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba2117d

Browse files
Fix panic
1 parentc0ecac0 commitba2117d

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

‎stack-graphs/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on[Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
##v0.14.1 -- Unpublished
9+
10+
###Fixed
11+
12+
- A panic when using`StackGraph::incoming_edge_degree` on some nodes without incoming edges.
13+
814
##v0.14.0 -- 2024-07-09
915

1016
###Changed

‎stack-graphs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name ="stack-graphs"
3-
version ="0.14.0"
3+
version ="0.14.1"
44
description ="Name binding for arbitrary programming languages"
55
homepage ="https://github.com/github/stack-graphs/tree/main/stack-graphs"
66
repository ="https://github.com/github/stack-graphs/"

‎stack-graphs/src/graph.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,10 @@ impl StackGraph {
13341334

13351335
/// Returns the number of edges that end at a particular sink node.
13361336
pubfnincoming_edge_degree(&self,sink:Handle<Node>) ->Degree{
1337-
self.incoming_edges[sink]
1337+
self.incoming_edges
1338+
.get(sink)
1339+
.cloned()
1340+
.unwrap_or(Degree::Zero)
13381341
}
13391342
}
13401343

‎stack-graphs/tests/it/graph.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use std::collections::HashSet;
99

1010
use maplit::hashset;
11-
use stack_graphs::graph::StackGraph;
11+
use stack_graphs::graph::{Degree,StackGraph};
1212

1313
usecrate::test_graphs;
1414
usecrate::test_graphs::CreateStackGraph;
@@ -196,3 +196,22 @@ fn can_add_graph_to_empty_graph() {
196196
);
197197
}
198198
}
199+
200+
#[test]
201+
fncan_get_incoming_edges(){
202+
letmut graph =StackGraph::new();
203+
let file = graph.get_or_create_file("test.py");
204+
let h1 = graph.internal_scope(file,0);
205+
let h2 = graph.internal_scope(file,1);
206+
let h3 = graph.internal_scope(file,2);
207+
assert_eq!(Degree::Zero, graph.incoming_edge_degree(h1));
208+
assert_eq!(Degree::Zero, graph.incoming_edge_degree(h2));
209+
assert_eq!(Degree::Zero, graph.incoming_edge_degree(h3));
210+
graph.add_edge(h1, h2,0);
211+
graph.add_edge(h3, h2,0);
212+
assert_eq!(Degree::Zero, graph.incoming_edge_degree(h1));
213+
assert_eq!(Degree::Multiple, graph.incoming_edge_degree(h2));
214+
assert_eq!(Degree::Zero, graph.incoming_edge_degree(h3));
215+
graph.add_edge(h3, h1,0);
216+
assert_eq!(Degree::One, graph.incoming_edge_degree(h1));
217+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp