Skip to content

Parens must be kept around sequential exprs with semicolons in record field assignments #17826

Closed

Description

@brianrourkeboll

Repro

let B = 2
// Analyzer suggests removing parens,
// but that changes the entire parsing of the expression…
let foo = {| A = ((); B = 3) |}
// …or causes a parsing error.
let bar = {| A = ((); ()) |}

Expected behavior

SynExpr.shouldBeParenthesizedInContext should return true anywhere the semicolon is required for the sequential expression to compile:

One-liner sequential exprs

let B = 2
let foo = {| A = ((); B = 3) |}

Indentation-sensitive/offsides sequential exprs

let B = 2
let foo =
    {| A =
        (();
        B = 2) |}

Actual behavior

It returns false, and the analyzer suggests removing unnecessary parentheses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-LangService-CodeRefactoringsSuggested but not necessary code actions. Screwdrivers in VS.BugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions