Skip to content

Commit b803573

Browse files
committed
Adding new compiler, lowerer is now infallible (#2239)
1 parent 9f8d6db commit b803573

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3066
-1509
lines changed

compiler/qsc_qasm3/src/ast_builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,14 @@ pub(crate) fn build_stmt_semi_from_expr(expr: Expr) -> Stmt {
859859
}
860860
}
861861

862+
pub(crate) fn build_stmt_semi_from_expr_with_span(expr: Expr, span: Span) -> Stmt {
863+
Stmt {
864+
id: NodeId::default(),
865+
span,
866+
kind: Box::new(StmtKind::Semi(Box::new(expr))),
867+
}
868+
}
869+
862870
pub(crate) fn build_wrapped_block_expr(block: Block) -> Expr {
863871
Expr {
864872
id: NodeId::default(),

compiler/qsc_qasm3/src/compile/tests.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
use crate::tests::{parse_all, print_compilation_errors, qasm_to_program_fragments};
4+
use crate::tests::{compile_all_fragments, print_compilation_errors};
55
use miette::Report;
66

77
#[test]
@@ -18,9 +18,7 @@ fn programs_with_includes_with_includes_can_be_compiled() -> miette::Result<(),
1818
("source2.qasm".into(), source2.into()),
1919
];
2020

21-
let res = parse_all("source0.qasm", all_sources)?;
22-
assert!(!res.has_errors());
23-
let unit = qasm_to_program_fragments(res.source, res.source_map);
21+
let unit = compile_all_fragments("source0.qasm", all_sources)?;
2422
print_compilation_errors(&unit);
2523
assert!(!unit.has_errors());
2624
Ok(())
@@ -41,10 +39,7 @@ fn including_stdgates_multiple_times_causes_symbol_redifintion_errors(
4139
("source2.qasm".into(), source2.into()),
4240
];
4341

44-
let res = parse_all("source0.qasm", all_sources)?;
45-
assert!(!res.has_errors());
46-
let unit = qasm_to_program_fragments(res.source, res.source_map);
47-
42+
let unit = compile_all_fragments("source0.qasm", all_sources)?;
4843
assert!(unit.has_errors());
4944
for error in unit.errors() {
5045
assert!(error.to_string().contains("Redefined symbol: "));

0 commit comments

Comments
 (0)