mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-02 05:48:17 +00:00
Fix negative float and non-base-10 literal patterns
This commit is contained in:
parent
962534e3d1
commit
f08a0012ea
5 changed files with 56 additions and 2 deletions
|
|
@ -294,7 +294,8 @@ fn fmt_pattern_only(
|
||||||
is_negative,
|
is_negative,
|
||||||
} => {
|
} => {
|
||||||
buf.indent(indent);
|
buf.indent(indent);
|
||||||
let needs_parens = parens == Parens::InClosurePattern;
|
let needs_parens = parens == Parens::InClosurePattern
|
||||||
|
|| (parens == Parens::InPncApplyFunc && *is_negative);
|
||||||
if needs_parens {
|
if needs_parens {
|
||||||
buf.push('(');
|
buf.push('(');
|
||||||
}
|
}
|
||||||
|
|
@ -317,7 +318,8 @@ fn fmt_pattern_only(
|
||||||
}
|
}
|
||||||
Pattern::FloatLiteral(string) => {
|
Pattern::FloatLiteral(string) => {
|
||||||
buf.indent(indent);
|
buf.indent(indent);
|
||||||
let needs_parens = parens == Parens::InClosurePattern;
|
let needs_parens = parens == Parens::InClosurePattern
|
||||||
|
|| (parens == Parens::InPncApplyFunc && string.starts_with('-'));
|
||||||
if needs_parens {
|
if needs_parens {
|
||||||
buf.push('(');
|
buf.push('(');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
(-8.)() : C
|
||||||
|
p
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
@0-11 SpaceAfter(
|
||||||
|
Defs(
|
||||||
|
Defs {
|
||||||
|
tags: [
|
||||||
|
EitherIndex(2147483648),
|
||||||
|
],
|
||||||
|
regions: [
|
||||||
|
@0-9,
|
||||||
|
],
|
||||||
|
space_before: [
|
||||||
|
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||||
|
],
|
||||||
|
space_after: [
|
||||||
|
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||||
|
],
|
||||||
|
spaces: [],
|
||||||
|
type_defs: [],
|
||||||
|
value_defs: [
|
||||||
|
Annotation(
|
||||||
|
@1-7 PncApply(
|
||||||
|
@1-4 FloatLiteral(
|
||||||
|
"-8.",
|
||||||
|
),
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
@8-9 Apply(
|
||||||
|
"",
|
||||||
|
"C",
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
@10-11 SpaceBefore(
|
||||||
|
Var {
|
||||||
|
module_name: "",
|
||||||
|
ident: "p",
|
||||||
|
},
|
||||||
|
[
|
||||||
|
Newline,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
[
|
||||||
|
Newline,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
(-8.)():C
|
||||||
|
p
|
||||||
|
|
@ -550,6 +550,7 @@ mod test_snapshots {
|
||||||
pass/multiline_type_signature_with_comment.expr,
|
pass/multiline_type_signature_with_comment.expr,
|
||||||
pass/multiple_fields.expr,
|
pass/multiple_fields.expr,
|
||||||
pass/multiple_operators.expr,
|
pass/multiple_operators.expr,
|
||||||
|
pass/neg_float_literal_pnc_apply_pat.expr,
|
||||||
pass/neg_inf_float.expr,
|
pass/neg_inf_float.expr,
|
||||||
pass/neg_nested_parens.expr,
|
pass/neg_nested_parens.expr,
|
||||||
pass/neg_newline_four.expr,
|
pass/neg_newline_four.expr,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue