Skip to content

Match expression inside match expression leads to offside error. #12011

@nojaf

Description

@nojaf

I believe I found a regression when it comes to the offside warnings.

Repro steps

When getting the untyped AST from the following example:

let u = ""

match!
    match! u with
    | null -> ""
    | s -> s
    with
| "" -> x
| _ -> failwith ""

An offside error will be reported. [|tmp.fsx (9,1)-(9,2) parse warning Possible incorrect indentation: this token is offside of context started at position (5:5). Try indenting this token further or using standard formatting conventions.|]

This does not occur when the match expression is multiline but without a match expression.

let u = ""

match!
    someLongFunctionApplication
        arg1
        arg2
        arg3
    with
| "" -> x
| _ -> failwith ""

Expected behavior

In FCS 39 no warnings were produced.

Actual behavior

Offside errors only in the cases where the match expression is a match (bang) expression.

Known workarounds

The indentation of the original code could be changed to get around this warning:

let u = ""

match!
    match! u with
    | null -> ""
    | s -> s
with
| "" -> x
| _ -> failwith ""

This is also valid but not in the current version of F#.

Related information

Provide any related information (optional):

FSharp.Compiler.Service 40.0.1-preview.21418.3

I suspect the recent changes of @Happypig375 might be related here.
//cc @dsyme

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions