From 1b2124dee920ff8f14c5a3fab26d1533ffc73d72 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 2 Aug 2024 16:05:43 +0200 Subject: [PATCH] Add failing test --- tests/Elm/Parser/FileTests.elm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Elm/Parser/FileTests.elm b/tests/Elm/Parser/FileTests.elm index 5fcff4975..9a712c922 100644 --- a/tests/Elm/Parser/FileTests.elm +++ b/tests/Elm/Parser/FileTests.elm @@ -468,4 +468,17 @@ port sendResponse : String -> Cmd msg , comments = [ Node { start = { row = 6, column = 1 }, end = { row = 7, column = 3 } } "{-| foo\n-}" ] } ) + , test "A file with a large number of comments should not create a stack overflow" <| + \() -> + let + comments : String + comments = + String.repeat 3000 "-- a\n" + in + ("""module Foo exposing (..) +a = 1 +""" ++ comments) + |> Elm.Parser.parseToFile + |> Result.map (\ast -> List.length ast.comments) + |> Expect.equal (Ok 3000) ]