Open Blaisorblade opened 7 years ago
This fits the general theme of:
Actually, I just discovered that this is a general problem if you try to implicitly format anything that's not recognized properly. So even in Haskell mode, the definition and use of the following formatting directive causes a stack overflow:
https://github.com/kosmikus/lhs2tex/issues/33#issuecomment-29065363
I suspect having a configurable maximum expansion depth (defaulting, say, to 1000) would be the most robust fix for all the "infinite loop" issues (especially for actual infinite loops, which can't be fixed otherwise).
The following loops and leaks memory quickly. This got my lhs2TeX up to 23GB RAM usage—took me a while to kill it. Replacing
Bar
bybar
fixes it—becauseBar
is not a valid variable name. I understand I made a mistake, but I imagine in principle this could be reported better than by looping.Parsing is done at https://github.com/kosmikus/lhs2tex/blob/master/src/Directives.lhs#L121-L122 and at https://github.com/kosmikus/lhs2tex/blob/master/src/Directives.lhs#L53-L64.
It seems my directive somehow passes the parser, because
gives a syntax error.
The same happens with
1bar
rather thanBar
:%format baz 1bar = "hi"
loops but%format (baz 1bar) = "hi"
gives a syntax error.It seems the equation is parsed successfully but it's not clear how and to what.