diff --git a/compiler/can/src/expr.rs b/compiler/can/src/expr.rs index 02c2861430..d12bc9b2ae 100644 --- a/compiler/can/src/expr.rs +++ b/compiler/can/src/expr.rs @@ -725,10 +725,11 @@ pub fn canonicalize_expr<'a>( } ast::Expr::MalformedIdent(name) => { use roc_problem::can::RuntimeError::*; - ( - RuntimeError(MalformedIdentifier((*name).into(), region)), - Output::default(), - ) + + let problem = MalformedIdentifier((*name).into(), region); + env.problem(Problem::RuntimeError(problem.clone())); + + (RuntimeError(problem), Output::default()) } ast::Expr::Nested(sub_expr) => { let (answer, output) = canonicalize_expr(env, var_store, scope, region, sub_expr); diff --git a/compiler/reporting/src/error/canonicalize.rs b/compiler/reporting/src/error/canonicalize.rs index 07856de1c5..a5b2925421 100644 --- a/compiler/reporting/src/error/canonicalize.rs +++ b/compiler/reporting/src/error/canonicalize.rs @@ -427,8 +427,15 @@ fn pretty_runtime_error<'b>( // do nothing, reported with PrecedenceProblem unreachable!() } - RuntimeError::MalformedIdentifier(_, _) => { - todo!("malformed identifier, currently gives a parse error and thus is unreachable") + RuntimeError::MalformedIdentifier(box_str, region) => { + alloc.stack(vec![ + alloc.concat(vec![ + alloc.reflow("The ") + .append(format!("`{}`", box_str)) + .append(alloc.reflow(" identifier is malformed:")), + ]), + alloc.region(region), + ]) } RuntimeError::MalformedClosure(_) => todo!(""), RuntimeError::InvalidFloat(sign @ FloatErrorKind::PositiveInfinity, region, _raw_str) diff --git a/compiler/reporting/tests/test_reporting.rs b/compiler/reporting/tests/test_reporting.rs index bbb8da2d86..10fa903e8b 100644 --- a/compiler/reporting/tests/test_reporting.rs +++ b/compiler/reporting/tests/test_reporting.rs @@ -3930,4 +3930,25 @@ mod test_reporting { ), ) } + + #[test] + fn qualified_global_tag() { + report_problem_as( + indoc!( + r#" + Foo.Bar + "# + ), + indoc!( + r#" + ── SYNTAX PROBLEM ────────────────────────────────────────────────────────────── + + The `Foo.Bar` identifier is malformed: + + 1│ Foo.Bar + ^^^^^^^ + "# + ), + ) + } }