Skip to content

Conversation

@0101
Copy link
Contributor

@0101 0101 commented Jan 26, 2023

Fixes #11667

@0101 0101 requested a review from a team as a code owner January 26, 2023 12:20
Copy link
Member

@vzarytovskii vzarytovskii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@vzarytovskii vzarytovskii enabled auto-merge (squash) January 26, 2023 12:31
Copy link
Member

@abonie abonie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a unit test too?

@0101
Copy link
Contributor Author

0101 commented Jan 26, 2023

Should there be a unit test too?

Probably. Although testing for stack overflow can be tricky.

@vzarytovskii vzarytovskii merged commit 035d908 into dotnet:main Jan 26, 2023
@nojaf
Copy link
Contributor

nojaf commented Jan 30, 2023

Probably. Although testing for stack overflow can be tricky.

In Fantomas, we had a similar problem once. I've added the following test to reproduce the problem:

[<Test>]
let ``avoid stack-overflow in long array/list, 2485`` () =
    let mkStringExpr () =
        SynExpr.Const(
            SynConst.String((System.Guid.NewGuid().ToString("N"), SynStringKind.Regular, Range.Zero)),
            Range.Zero
        )

    let longArrayExpr: SynExpr =
        let rec mkArray count childExpr =
            if count = 20_000 then
                childExpr
            else
                mkArray
                    (count + 1)
                    (SynExpr.Sequential(
                        DebugPointAtSequential.SuppressNeither,
                        true,
                        mkStringExpr (),
                        childExpr,
                        Range.Zero
                    ))

        SynExpr.ArrayOrListComputed(true, mkArray 0 (mkStringExpr ()), Range.Zero)

    let ast =
        ParsedInput.ImplFile(
            ParsedImplFileInput(
                "filename.fsx",
                true,
                QualifiedNameOfFile(Ident("", Range.Zero)),
                [],
                [],
                [ SynModuleOrNamespace(
                      [],
                      false,
                      SynModuleOrNamespaceKind.AnonModule,
                      [ SynModuleDecl.Expr(longArrayExpr, Range.Zero) ],
                      PreXmlDoc.Empty,
                      [],
                      None,
                      Range.Zero,
                      { LeadingKeyword = SynModuleOrNamespaceLeadingKeyword.None }
                  ) ],
                (false, false),
                { ConditionalDirectives = []
                  CodeComments = [] },
                Set.empty
            )
        )

    let _rootNode = ASTTransformer.mkOak None ast
    Assert.Pass()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Visual Studio hangs/crashes when hovering over a nonexistent union case pattern

4 participants