Last active
March 6, 2017 18:42
-
-
Save cscalfani/8c84015c4ce34a31c06776b67cd57ef1 to your computer and use it in GitHub Desktop.
Elm 0.18 Pattern Matching compiler bug (uses Gigabytes of memory, 100% CPU and forever to compile)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bug exposing (..) | |
{-| Uses tons of CPU, time to compile and Gigbytes of memory. It's exponetially worse the more cases there are. | |
The gigabytes of memory happen when the first of the 3-tuple is the same. Change the tuples to have the x0, x1, etc as the first and the memory issue disappears but not the CPU or time to compile. | |
Also starts to be a real problem 3-tuple and higher. | |
-} | |
bug : String | |
bug = | |
let | |
x = | |
( "a", "a", "x" ) | |
in | |
case x of | |
( "x", "x0", "x" ) -> | |
"" | |
( "x", "x1", "x" ) -> | |
"" | |
( "x", "x2", "x" ) -> | |
"" | |
( "x", "x3", "x" ) -> | |
"" | |
( "x", "x4", "x" ) -> | |
"" | |
( "x", "x5", "x" ) -> | |
"" | |
( "x", "x6", "x" ) -> | |
"" | |
( "x", "x7", "x" ) -> | |
"" | |
( "x", "x8", "x" ) -> | |
"" | |
( "x", "x9", "x" ) -> | |
"" | |
( "x", "x10", "x" ) -> | |
"" | |
( "x", "x11", "x" ) -> | |
"" | |
( "x", "x12", "x" ) -> | |
"" | |
( "x", "x13", "x" ) -> | |
"" | |
( "x", "x14", "x" ) -> | |
"" | |
( "x", "x15", "x" ) -> | |
"" | |
( "x", "x16", "x" ) -> | |
"" | |
( "x17", "x", "x" ) -> | |
"" | |
_ -> | |
Debug.crash "You forgot something" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment