Last active
November 10, 2017 12:06
-
-
Save hugoabonizio/82bb6ca249f15de03a21ce8d9deeb924 to your computer and use it in GitHub Desktop.
This program breaks Crystal compiler
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
a = {1, 0} | |
b = {a, a} | |
c = {b, b} | |
d = {c, c} | |
e = {d, d} | |
f = {e, e} | |
g = {f, f} | |
h = {g, g} | |
i = {h, h} | |
j = {i, i} | |
k = {j, j} | |
l = {k, k} | |
m = {l, l} | |
n = {m, m} | |
o = {n, n} | |
p = {o, o} | |
q = {p, p} | |
puts q |
b
written twice. Is this intentional ?
b = {a, a}
b = {a, a}
@veelenga not needed, I can't test it right now, but the principle is that the faculty ^2 we are dealing with is breaking the stack I guess. There are 2 ^ 18 = 262144 Integers. Considering an Integer to be 32bit (not sure what the implementation is) we get 8388608bit, or rather 8192Mib or 1GiB. Depending on how the stack is implemented I can easily see that blowing it up.
Note that you can't really avoid that problem, since you could just add more and more "levels", but maybe you would search for a way to optimize it and maybe make the issue clearer?
This is a cool bug
@veelenga this wasn't intentional, I fixed it now! Thanks!
@JonnyCodewalker thank you for the explanation 😃
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://carc.in/#/r/32gv