Skip to content

Commit

Permalink
emtpy_contract_impl fix (FuelLabs#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadfawaz authored Mar 4, 2022
1 parent 67054d7 commit 6ede1d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion forc/src/utils/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ fn construct_window<'a>(
let total_lines_in_input = input.chars().filter(|x| *x == '\n').count();
debug_assert!(end.line >= start.line);
let total_lines_of_highlight = end.line - start.line;
debug_assert!(total_lines_in_input > total_lines_of_highlight);
debug_assert!(total_lines_in_input >= total_lines_of_highlight);

let mut current_line = 0;
let mut lines_to_start_of_snippet = 0;
Expand Down
22 changes: 14 additions & 8 deletions sway-core/src/control_flow_analysis/analyze_return_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ impl ControlFlowGraph {
.filter(|idx| *idx != exit_point)
.collect();
let mut next_rovers = vec![];
let mut last_discovered_span = None;
let mut last_discovered_span;
for rover in rovers {
if let ControlFlowGraphNode::ProgramNode(ref node) = self.graph[rover] {
last_discovered_span = Some(node.span.clone());
}
last_discovered_span = match &self.graph[rover] {
ControlFlowGraphNode::ProgramNode(node) => Some(node.span.clone()),
ControlFlowGraphNode::MethodDeclaration { span, .. } => Some(span.clone()),
_ => None,
};

let mut neighbors = self
.graph
Expand All @@ -94,10 +96,14 @@ impl ControlFlowGraph {
let span = match last_discovered_span {
Some(ref o) => o.clone(),
None => {
errors.push(CompileError::Internal("Attempted to construct return path error but no source span was found.", Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None
}));
errors.push(CompileError::Internal(
"Attempted to construct return path error \
but no source span was found.",
Span {
span: pest::Span::new(" ".into(), 0, 0).unwrap(),
path: None,
},
));
return errors;
}
};
Expand Down

0 comments on commit 6ede1d2

Please sign in to comment.