Skip to content

Ignore Dependency Errors when Getting Documentation #2374

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion wasm/src/debug_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub fn init_debugger(
entry: Option<String>,
) -> Result<Debugger, Vec<Error>> {
let (source_map, capabilities, language_features, package_store, user_code_dependencies) =
into_qsc_args(program, entry)
into_qsc_args(program, entry, false)
.map_err(|e| e.into_iter().map(Into::into).collect::<Vec<_>>())?;

Debugger::new(
Expand Down
12 changes: 6 additions & 6 deletions wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn get_qir(program: ProgramConfig) -> Result<String, String> {
get_qir_from_openqasm(&sources, capabilities)
} else {
let (source_map, capabilities, language_features, store, deps) =
into_qsc_args(program, None).map_err(compile_errors_into_qsharp_errors_json)?;
into_qsc_args(program, None, false).map_err(compile_errors_into_qsharp_errors_json)?;

get_qir_from_qsharp(
source_map,
Expand Down Expand Up @@ -103,7 +103,7 @@ pub fn get_estimates(program: ProgramConfig, expr: &str, params: &str) -> Result
get_estimates_from_openqasm(&sources, capabilities, params)
} else {
let (source_map, capabilities, language_features, store, deps) =
into_qsc_args(program, Some(expr.into())).map_err(|mut e| {
into_qsc_args(program, Some(expr.into()), false).map_err(|mut e| {
// Wrap in `interpret::Error` to match the error type from `Interpreter::new` below
qsc::interpret::Error::from(e.pop().expect("expected at least one error"))
.to_string()
Expand Down Expand Up @@ -157,7 +157,7 @@ pub fn get_circuit(
serde_wasm_bindgen::to_value(&circuit).map_err(|e| e.to_string())
} else {
let (source_map, capabilities, language_features, store, deps) =
into_qsc_args(program, None).map_err(compile_errors_into_qsharp_errors_json)?;
into_qsc_args(program, None, false).map_err(compile_errors_into_qsharp_errors_json)?;

let (package_type, entry_point) = match operation {
Some(p) => {
Expand Down Expand Up @@ -269,7 +269,7 @@ pub fn get_hir(
#[wasm_bindgen]
pub fn get_rir(program: ProgramConfig) -> Result<Vec<String>, String> {
let (source_map, capabilities, language_features, store, deps) =
into_qsc_args(program, None).map_err(compile_errors_into_qsharp_errors_json)?;
into_qsc_args(program, None, false).map_err(compile_errors_into_qsharp_errors_json)?;

qsc::codegen::qir::get_rir(
source_map,
Expand Down Expand Up @@ -528,7 +528,7 @@ pub fn runWithPauliNoise(
Ok(true)
} else {
let (source_map, capabilities, language_features, store, deps) =
into_qsc_args(program, Some(expr.into())).map_err(|mut e| {
into_qsc_args(program, Some(expr.into()), false).map_err(|mut e| {
// Wrap in `interpret::Error` and `JsError` to match the error type
// `run_internal_with_features` below
JsError::from(qsc::interpret::Error::from(
Expand Down Expand Up @@ -621,7 +621,7 @@ serializable_type! {
pub fn generate_docs(additional_program: Option<ProgramConfig>) -> Vec<IDocFile> {
let docs = if let Some(additional_program) = additional_program {
let Ok((source_map, capabilities, language_features, package_store, dependencies)) =
into_qsc_args(additional_program, None)
into_qsc_args(additional_program, None, true)
else {
// Can't generate docs if building dependencies failed
return Vec::new();
Expand Down
3 changes: 2 additions & 1 deletion wasm/src/project_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ impl From<PackageInfo> for qsc_project::PackageInfo {
pub(crate) fn into_qsc_args(
program: ProgramConfig,
entry: Option<String>,
ignore_dependency_errors: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

ignore_dependency_errors is kind of a negation built into variable name. Consider fail_on_dependency_errors or something similar instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about this in terms of the "default" value being false, even though Rust doesn't actually have default values, so that you'd get the usual behavior passing false in, and would get the updated behavior by passing true. In this case the updated behavior is a suppression of errors. I can see what you mean by it being a bit of a negation in that you pass in true to make it do less.

) -> Result<
(
qsc::SourceMap,
Expand All @@ -420,7 +421,7 @@ pub(crate) fn into_qsc_args(
// for building the user code.
let buildable_program = BuildableProgram::new(capabilities, pkg_graph);

if !buildable_program.dependency_errors.is_empty() {
if !ignore_dependency_errors && !buildable_program.dependency_errors.is_empty() {
return Err(buildable_program.dependency_errors);
}

Expand Down
Loading