fix: map fallback name if present to else
This commit is contained in:
parent
00907c2bcc
commit
cf3180996a
|
@ -129,7 +129,7 @@ Validator(
|
||||||
},
|
},
|
||||||
doc: None,
|
doc: None,
|
||||||
location: 103..106,
|
location: 103..106,
|
||||||
name: "temp",
|
name: "else",
|
||||||
public: true,
|
public: true,
|
||||||
return_annotation: None,
|
return_annotation: None,
|
||||||
return_type: (),
|
return_type: (),
|
||||||
|
|
|
@ -29,7 +29,15 @@ pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError
|
||||||
function
|
function
|
||||||
})
|
})
|
||||||
.repeated()
|
.repeated()
|
||||||
.then(just(Token::Else).ignore_then(args_and_body()).or_not())
|
.then(
|
||||||
|
just(Token::Else)
|
||||||
|
.ignore_then(args_and_body().map(|mut function| {
|
||||||
|
function.name = "else".to_string();
|
||||||
|
|
||||||
|
function
|
||||||
|
}))
|
||||||
|
.or_not(),
|
||||||
|
)
|
||||||
.delimited_by(just(Token::LeftBrace), just(Token::RightBrace)),
|
.delimited_by(just(Token::LeftBrace), just(Token::RightBrace)),
|
||||||
)
|
)
|
||||||
.map_with_span(
|
.map_with_span(
|
||||||
|
|
|
@ -175,6 +175,6 @@ macro_rules! assert_format {
|
||||||
let (module2, extra2) = $crate::parser::module(&out, $crate::ast::ModuleKind::Lib).unwrap();
|
let (module2, extra2) = $crate::parser::module(&out, $crate::ast::ModuleKind::Lib).unwrap();
|
||||||
let mut out2 = String::new();
|
let mut out2 = String::new();
|
||||||
$crate::format::pretty(&mut out2, module2, extra2, &out);
|
$crate::format::pretty(&mut out2, module2, extra2, &out);
|
||||||
assert_eq!(out, out2, "formatting isn't idempotent");
|
pretty_assertions::assert_eq!(out, out2, "formatting isn't idempotent");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue