mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
report malformed int and float patterns
This commit is contained in:
parent
a05b664be0
commit
0c7a4179aa
8 changed files with 208 additions and 27 deletions
|
@ -338,6 +338,28 @@ fn pretty_runtime_error<'b>(
|
|||
])
|
||||
}
|
||||
}
|
||||
RuntimeError::MalformedPattern(problem, region) => {
|
||||
use roc_parse::ast::Base;
|
||||
use roc_problem::can::MalformedPatternProblem::*;
|
||||
|
||||
let name = match problem {
|
||||
MalformedInt => "integer",
|
||||
MalformedFloat => "float",
|
||||
MalformedBase(Base::Hex) => "hex integer",
|
||||
MalformedBase(Base::Binary) => "binary integer",
|
||||
MalformedBase(Base::Octal) => "octal integer",
|
||||
};
|
||||
|
||||
alloc.stack(vec![
|
||||
alloc.concat(vec![
|
||||
alloc.reflow("This "),
|
||||
alloc.text(name),
|
||||
alloc.reflow(" pattern is malformed:"),
|
||||
]),
|
||||
alloc.region(region),
|
||||
])
|
||||
}
|
||||
|
||||
other => {
|
||||
// // Example: (5 = 1 + 2) is an unsupported pattern in an assignment; Int patterns aren't allowed in assignments!
|
||||
// UnsupportedPattern(Region),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue