mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 00:09:33 +03:00
working parser error
This commit is contained in:
parent
719ef5b70e
commit
aea48f703a
@ -1244,12 +1244,12 @@ pub fn ident_etc<'a>(min_indent: u16) -> impl Parser<'a, Expr<'a>> {
|
||||
move |arena, state, (loc_ident, opt_extras)| {
|
||||
// This appears to be a var, keyword, or function application.
|
||||
match opt_extras {
|
||||
(Some(_loc_args), Some((_spaces_before_equals, Either::First(_equals_indent)))) => {
|
||||
// We got args with an '=' after them, e.g. `foo a b = ...`
|
||||
// This is a syntax error!
|
||||
(Some(loc_args), Some((_spaces_before_equals, Either::First(_equals_indent)))) => {
|
||||
// We got args with an '=' after them, e.g. `foo a b = ...` This is a syntax error!
|
||||
let region = Region::across_all(loc_args.iter().map(|v| &v.region));
|
||||
let fail = Fail {
|
||||
attempting: state.attempting,
|
||||
reason: FailReason::ArgumentsBeforeEquals,
|
||||
reason: FailReason::ArgumentsBeforeEquals(region),
|
||||
};
|
||||
Err((fail, state))
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ pub enum FailReason {
|
||||
Eof(Region),
|
||||
InvalidPattern,
|
||||
ReservedKeyword(Region),
|
||||
ArgumentsBeforeEquals,
|
||||
ArgumentsBeforeEquals(Region),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -12,8 +12,11 @@ pub fn parse_problem<'b>(
|
||||
use FailReason::*;
|
||||
|
||||
match problem.reason {
|
||||
ArgumentsBeforeEquals => {
|
||||
let doc = alloc.text("Unexpected tokens in front of the `=` symbol:");
|
||||
ArgumentsBeforeEquals(region) => {
|
||||
let doc = alloc.stack(vec![
|
||||
alloc.reflow("Unexpected tokens in front of the `=` symbol:"),
|
||||
alloc.region(region),
|
||||
]);
|
||||
|
||||
Report {
|
||||
filename,
|
||||
|
@ -1,7 +1,6 @@
|
||||
extern crate bumpalo;
|
||||
|
||||
use self::bumpalo::Bump;
|
||||
use roc_builtins::unique::uniq_stdlib;
|
||||
use roc_can::constraint::Constraint;
|
||||
use roc_can::env::Env;
|
||||
use roc_can::expected::Expected;
|
||||
@ -11,13 +10,12 @@ use roc_can::scope::Scope;
|
||||
use roc_collections::all::{ImMap, MutMap, SendMap, SendSet};
|
||||
use roc_constrain::expr::constrain_expr;
|
||||
use roc_constrain::module::{constrain_imported_values, load_builtin_aliases, Import};
|
||||
use roc_module::ident::Ident;
|
||||
use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds, Symbol};
|
||||
use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds};
|
||||
use roc_parse::ast::{self, Attempting};
|
||||
use roc_parse::blankspace::space0_before;
|
||||
use roc_parse::parser::{loc, Fail, Parser, State};
|
||||
use roc_problem::can::Problem;
|
||||
use roc_region::all::{Located, Region};
|
||||
use roc_region::all::Located;
|
||||
use roc_solve::solve;
|
||||
use roc_types::subs::{Content, Subs, VarStore, Variable};
|
||||
use roc_types::types::Type;
|
||||
|
@ -2704,8 +2704,11 @@ mod test_reporting {
|
||||
indoc!(
|
||||
r#"
|
||||
-- PARSE PROBLEM ---------------------------------------------------------------
|
||||
|
||||
|
||||
Unexpected tokens in front of the `=` symbol:
|
||||
|
||||
1 ┆ f x y = x
|
||||
┆ ^^^
|
||||
"#
|
||||
),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user