Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicated errors and warnings. #1112

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 38 additions & 18 deletions sway-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,31 +310,51 @@ pub fn compile_to_ast(
) -> CompileAstResult {
let mut warnings = Vec::new();
let mut errors = Vec::new();
let parse_tree = check!(
parse(input, Some(build_config)),
return CompileAstResult::Failure { errors, warnings },
warnings,
errors
);

let CompileResult {
value: parse_tree_result,
warnings: new_warnings,
errors: new_errors,
} = parse(input, Some(build_config));
warnings.extend(new_warnings);
errors.extend(new_errors);
let parse_tree = match parse_tree_result {
Some(parse_tree) => parse_tree,
None => {
errors = dedup_unsorted(errors);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

warnings = dedup_unsorted(warnings);
return CompileAstResult::Failure { errors, warnings };
}
};

let mut dead_code_graph = ControlFlowGraph {
graph: Graph::new(),
entry_points: vec![],
namespace: Default::default(),
};

let typed_parse_tree = check!(
TypedParseTree::type_check(
parse_tree.tree,
initial_namespace,
initial_namespace,
&parse_tree.tree_type,
&build_config.clone(),
&mut dead_code_graph,
),
return CompileAstResult::Failure { errors, warnings },
warnings,
errors
let CompileResult {
value: typed_parse_tree_result,
warnings: new_warnings,
errors: new_errors,
} = TypedParseTree::type_check(
parse_tree.tree,
initial_namespace,
initial_namespace,
&parse_tree.tree_type,
&build_config.clone(),
&mut dead_code_graph,
);
warnings.extend(new_warnings);
errors.extend(new_errors);
let typed_parse_tree = match typed_parse_tree_result {
Some(typed_parse_tree) => typed_parse_tree,
None => {
errors = dedup_unsorted(errors);
warnings = dedup_unsorted(warnings);
return CompileAstResult::Failure { errors, warnings };
}
};

let (mut l_warnings, mut l_errors) = perform_control_flow_analysis(
&typed_parse_tree,
Expand Down