diff --git a/hydroflow/tests/compile-fail/surface_singleton_nostate.rs b/hydroflow/tests/compile-fail/surface_singleton_nostate.rs new file mode 100644 index 000000000000..d054776ba423 --- /dev/null +++ b/hydroflow/tests/compile-fail/surface_singleton_nostate.rs @@ -0,0 +1,10 @@ +pub fn main() { + let mut df = hydroflow::hydroflow_syntax! { + my_ref = source_iter(15..=25) -> null(); + source_iter(10..=30) + -> filter(|value| value <= #my_ref.as_reveal_ref()) + -> null(); + + }; + df.run_available(); +} diff --git a/hydroflow/tests/compile-fail/surface_singleton_nostate.stderr b/hydroflow/tests/compile-fail/surface_singleton_nostate.stderr new file mode 100644 index 000000000000..cabf25fd27ab --- /dev/null +++ b/hydroflow/tests/compile-fail/surface_singleton_nostate.stderr @@ -0,0 +1,20 @@ +error[E0425]: cannot find value `singleton_op_2v1` in this scope + --> tests/compile-fail/surface_singleton_nostate.rs:5:16 + | +5 | -> filter(|value| value <= #my_ref.as_reveal_ref()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0282]: type annotations needed + --> tests/compile-fail/surface_singleton_nostate.rs:2:18 + | +2 | let mut df = hydroflow::hydroflow_syntax! { + | __________________^ +3 | | my_ref = source_iter(15..=25) -> null(); +4 | | source_iter(10..=30) +5 | | -> filter(|value| value <= #my_ref.as_reveal_ref()) +6 | | -> null(); +7 | | +8 | | }; + | |_____^ cannot infer type + | + = note: this error originates in the macro `hydroflow::hydroflow_syntax` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/hydroflow/tests/compile-fail/surface_singleton_nostate_undefined.rs b/hydroflow/tests/compile-fail/surface_singleton_nostate_undefined.rs new file mode 100644 index 000000000000..eaeb1f47f8dd --- /dev/null +++ b/hydroflow/tests/compile-fail/surface_singleton_nostate_undefined.rs @@ -0,0 +1,9 @@ +pub fn main() { + let mut df = hydroflow::hydroflow_syntax! { + my_ref = source_iter(15..=25) -> null(); + source_iter(10..=30) + -> filter(|value| value <= #my_ref.as_reveal_ref() && value <= #unknown.as_reveal_ref()) + -> null(); + }; + df.run_available(); +} diff --git a/hydroflow/tests/compile-fail/surface_singleton_nostate_undefined.stderr b/hydroflow/tests/compile-fail/surface_singleton_nostate_undefined.stderr new file mode 100644 index 000000000000..05557611c6ec --- /dev/null +++ b/hydroflow/tests/compile-fail/surface_singleton_nostate_undefined.stderr @@ -0,0 +1,5 @@ +error: Cannot find referenced name `unknown`; name was never assigned. + --> tests/compile-fail/surface_singleton_nostate_undefined.rs:5:77 + | +5 | -> filter(|value| value <= #my_ref.as_reveal_ref() && value <= #unknown.as_reveal_ref()) + | ^^^^^^^ diff --git a/hydroflow/tests/compile-fail/surface_singleton_undefined.rs b/hydroflow/tests/compile-fail/surface_singleton_undefined.rs new file mode 100644 index 000000000000..2e0966f46977 --- /dev/null +++ b/hydroflow/tests/compile-fail/surface_singleton_undefined.rs @@ -0,0 +1,9 @@ +pub fn main() { + let mut df = hydroflow::hydroflow_syntax! { + source_iter(10..=30) + -> filter(|value| value <= #unknown.as_reveal_ref()) + -> null(); + + }; + df.run_available(); +} diff --git a/hydroflow/tests/compile-fail/surface_singleton_undefined.stderr b/hydroflow/tests/compile-fail/surface_singleton_undefined.stderr new file mode 100644 index 000000000000..ce916b48d01a --- /dev/null +++ b/hydroflow/tests/compile-fail/surface_singleton_undefined.stderr @@ -0,0 +1,5 @@ +error: Cannot find referenced name `unknown`; name was never assigned. + --> tests/compile-fail/surface_singleton_undefined.rs:4:41 + | +4 | -> filter(|value| value <= #unknown.as_reveal_ref()) + | ^^^^^^^ diff --git a/hydroflow/tests/compile-fail/surface_singleton_undefined_nostate.rs b/hydroflow/tests/compile-fail/surface_singleton_undefined_nostate.rs new file mode 100644 index 000000000000..f1168e081aa7 --- /dev/null +++ b/hydroflow/tests/compile-fail/surface_singleton_undefined_nostate.rs @@ -0,0 +1,9 @@ +pub fn main() { + let mut df = hydroflow::hydroflow_syntax! { + my_ref = source_iter(15..=25) -> null(); + source_iter(10..=30) + -> filter(|value| value <= #unknown.as_reveal_ref() && value <= #my_ref.as_reveal_ref()) + -> null(); + }; + df.run_available(); +} diff --git a/hydroflow/tests/compile-fail/surface_singleton_undefined_nostate.stderr b/hydroflow/tests/compile-fail/surface_singleton_undefined_nostate.stderr new file mode 100644 index 000000000000..c85b0627407d --- /dev/null +++ b/hydroflow/tests/compile-fail/surface_singleton_undefined_nostate.stderr @@ -0,0 +1,5 @@ +error: Cannot find referenced name `unknown`; name was never assigned. + --> tests/compile-fail/surface_singleton_undefined_nostate.rs:5:41 + | +5 | -> filter(|value| value <= #unknown.as_reveal_ref() && value <= #my_ref.as_reveal_ref()) + | ^^^^^^^ diff --git a/hydroflow/tests/compile-fail/surface_undefined_variable.rs b/hydroflow/tests/compile-fail/surface_varname_undefined.rs similarity index 100% rename from hydroflow/tests/compile-fail/surface_undefined_variable.rs rename to hydroflow/tests/compile-fail/surface_varname_undefined.rs diff --git a/hydroflow/tests/compile-fail/surface_undefined_variable.stderr b/hydroflow/tests/compile-fail/surface_varname_undefined.stderr similarity index 72% rename from hydroflow/tests/compile-fail/surface_undefined_variable.stderr rename to hydroflow/tests/compile-fail/surface_varname_undefined.stderr index db70c8762e2a..30e93b2321d5 100644 --- a/hydroflow/tests/compile-fail/surface_undefined_variable.stderr +++ b/hydroflow/tests/compile-fail/surface_varname_undefined.stderr @@ -1,11 +1,11 @@ error: Cannot find name `hydro_lab`; name was never assigned. - --> tests/compile-fail/surface_undefined_variable.rs:5:9 + --> tests/compile-fail/surface_varname_undefined.rs:5:9 | 5 | hydro_lab -> for_each(std::mem::drop); | ^^^^^^^^^ error: `for_each` must have exactly 1 input(s), actually has 0. - --> tests/compile-fail/surface_undefined_variable.rs:5:22 + --> tests/compile-fail/surface_varname_undefined.rs:5:22 | 5 | hydro_lab -> for_each(std::mem::drop); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/hydroflow_lang/src/graph/flat_graph_builder.rs b/hydroflow_lang/src/graph/flat_graph_builder.rs index 2f42a28d1e78..da9be0a92874 100644 --- a/hydroflow_lang/src/graph/flat_graph_builder.rs +++ b/hydroflow_lang/src/graph/flat_graph_builder.rs @@ -368,8 +368,19 @@ impl FlatGraphBuilder { .and_then(|result| result.as_ref().ok()) .and_then(|ends| ends.out.as_ref()) .cloned(); - let (_port, node_id) = self.helper_resolve_name(port_det, false)?; - Some(node_id) + if let Some((_port, node_id)) = self.helper_resolve_name(port_det, false) { + Some(node_id) + } else { + self.diagnostics.push(Diagnostic::spanned( + singleton_ref.span(), + Level::Error, + format!( + "Cannot find referenced name `{}`; name was never assigned.", + singleton_ref + ), + )); + None + } }) .collect();