mirror of
				https://github.com/roc-lang/roc.git
				synced 2025-11-03 22:13:35 +00:00 
			
		
		
		
	handle record access when checking for block string literals
This commit is contained in:
		
							parent
							
								
									6d2b635dbc
								
							
						
					
					
						commit
						875e355b68
					
				
					 5 changed files with 72 additions and 1 deletions
				
			
		| 
						 | 
					@ -1014,7 +1014,6 @@ pub fn fmt_body<'a>(
 | 
				
			||||||
    allow_simplify_empty_record_destructure: bool,
 | 
					    allow_simplify_empty_record_destructure: bool,
 | 
				
			||||||
    pattern: &'a Pattern<'a>,
 | 
					    pattern: &'a Pattern<'a>,
 | 
				
			||||||
    body: &'a Expr<'a>,
 | 
					    body: &'a Expr<'a>,
 | 
				
			||||||
 | 
					 | 
				
			||||||
    indent: u16,
 | 
					    indent: u16,
 | 
				
			||||||
) {
 | 
					) {
 | 
				
			||||||
    let pattern_extracted = pattern.extract_spaces();
 | 
					    let pattern_extracted = pattern.extract_spaces();
 | 
				
			||||||
| 
						 | 
					@ -1168,6 +1167,7 @@ pub fn starts_with_block_string_literal(expr: &Expr<'_>) -> bool {
 | 
				
			||||||
            starts_with_block_string_literal(inner)
 | 
					            starts_with_block_string_literal(inner)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Expr::Apply(inner, _, _) => starts_with_block_string_literal(&inner.value),
 | 
					        Expr::Apply(inner, _, _) => starts_with_block_string_literal(&inner.value),
 | 
				
			||||||
 | 
					        Expr::RecordAccess(inner, _) => starts_with_block_string_literal(inner),
 | 
				
			||||||
        Expr::PncApply(inner, _) => starts_with_block_string_literal(&inner.value),
 | 
					        Expr::PncApply(inner, _) => starts_with_block_string_literal(&inner.value),
 | 
				
			||||||
        Expr::TrySuffix(inner) => starts_with_block_string_literal(inner),
 | 
					        Expr::TrySuffix(inner) => starts_with_block_string_literal(inner),
 | 
				
			||||||
        _ => false,
 | 
					        _ => false,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					(
 | 
				
			||||||
 | 
					    e =
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        """().d
 | 
				
			||||||
 | 
					    e
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					    m
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,61 @@
 | 
				
			||||||
 | 
					@0-17 SpaceAfter(
 | 
				
			||||||
 | 
					    Apply(
 | 
				
			||||||
 | 
					        @1-15 ParensAround(
 | 
				
			||||||
 | 
					            Defs(
 | 
				
			||||||
 | 
					                Defs {
 | 
				
			||||||
 | 
					                    tags: [
 | 
				
			||||||
 | 
					                        EitherIndex(2147483648),
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                    regions: [
 | 
				
			||||||
 | 
					                        @1-13,
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                    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: [
 | 
				
			||||||
 | 
					                        Body(
 | 
				
			||||||
 | 
					                            @1-2 Identifier {
 | 
				
			||||||
 | 
					                                ident: "e",
 | 
				
			||||||
 | 
					                            },
 | 
				
			||||||
 | 
					                            @3-13 RecordAccess(
 | 
				
			||||||
 | 
					                                PncApply(
 | 
				
			||||||
 | 
					                                    @3-9 Str(
 | 
				
			||||||
 | 
					                                        Block(
 | 
				
			||||||
 | 
					                                            [],
 | 
				
			||||||
 | 
					                                        ),
 | 
				
			||||||
 | 
					                                    ),
 | 
				
			||||||
 | 
					                                    [],
 | 
				
			||||||
 | 
					                                ),
 | 
				
			||||||
 | 
					                                "d",
 | 
				
			||||||
 | 
					                            ),
 | 
				
			||||||
 | 
					                        ),
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                @14-15 SpaceBefore(
 | 
				
			||||||
 | 
					                    Var {
 | 
				
			||||||
 | 
					                        module_name: "",
 | 
				
			||||||
 | 
					                        ident: "e",
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                    [
 | 
				
			||||||
 | 
					                        Newline,
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                ),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					        [
 | 
				
			||||||
 | 
					            @16-17 Var {
 | 
				
			||||||
 | 
					                module_name: "",
 | 
				
			||||||
 | 
					                ident: "m",
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        Space,
 | 
				
			||||||
 | 
					    ),
 | 
				
			||||||
 | 
					    [
 | 
				
			||||||
 | 
					        Newline,
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,2 @@
 | 
				
			||||||
 | 
					(e=""""""().d
 | 
				
			||||||
 | 
					e)m
 | 
				
			||||||
| 
						 | 
					@ -529,6 +529,7 @@ mod test_snapshots {
 | 
				
			||||||
        pass/multiline_str_in_pat.expr,
 | 
					        pass/multiline_str_in_pat.expr,
 | 
				
			||||||
        pass/multiline_str_interpolation_records.expr,
 | 
					        pass/multiline_str_interpolation_records.expr,
 | 
				
			||||||
        pass/multiline_str_opt_field.expr,
 | 
					        pass/multiline_str_opt_field.expr,
 | 
				
			||||||
 | 
					        pass/multiline_str_pnc_apply_in_assignment_newline.expr,
 | 
				
			||||||
        pass/multiline_string.expr,
 | 
					        pass/multiline_string.expr,
 | 
				
			||||||
        pass/multiline_string_in_apply.expr,
 | 
					        pass/multiline_string_in_apply.expr,
 | 
				
			||||||
        pass/multiline_tuple_with_comments.expr,
 | 
					        pass/multiline_tuple_with_comments.expr,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue