mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
report a Foo.Bar
malformed identifier
This commit is contained in:
parent
10255a90b1
commit
c05ec12be0
3 changed files with 35 additions and 6 deletions
|
@ -725,10 +725,11 @@ pub fn canonicalize_expr<'a>(
|
||||||
}
|
}
|
||||||
ast::Expr::MalformedIdent(name) => {
|
ast::Expr::MalformedIdent(name) => {
|
||||||
use roc_problem::can::RuntimeError::*;
|
use roc_problem::can::RuntimeError::*;
|
||||||
(
|
|
||||||
RuntimeError(MalformedIdentifier((*name).into(), region)),
|
let problem = MalformedIdentifier((*name).into(), region);
|
||||||
Output::default(),
|
env.problem(Problem::RuntimeError(problem.clone()));
|
||||||
)
|
|
||||||
|
(RuntimeError(problem), Output::default())
|
||||||
}
|
}
|
||||||
ast::Expr::Nested(sub_expr) => {
|
ast::Expr::Nested(sub_expr) => {
|
||||||
let (answer, output) = canonicalize_expr(env, var_store, scope, region, sub_expr);
|
let (answer, output) = canonicalize_expr(env, var_store, scope, region, sub_expr);
|
||||||
|
|
|
@ -427,8 +427,15 @@ fn pretty_runtime_error<'b>(
|
||||||
// do nothing, reported with PrecedenceProblem
|
// do nothing, reported with PrecedenceProblem
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
RuntimeError::MalformedIdentifier(_, _) => {
|
RuntimeError::MalformedIdentifier(box_str, region) => {
|
||||||
todo!("malformed identifier, currently gives a parse error and thus is unreachable")
|
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::MalformedClosure(_) => todo!(""),
|
||||||
RuntimeError::InvalidFloat(sign @ FloatErrorKind::PositiveInfinity, region, _raw_str)
|
RuntimeError::InvalidFloat(sign @ FloatErrorKind::PositiveInfinity, region, _raw_str)
|
||||||
|
|
|
@ -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
|
||||||
|
^^^^^^^
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue