nimly
nimly copied to clipboard
nimly Uses Too Many Loops In Compile-time
You can avoid this error to use the new compiler option maxLoopIterationsVM:N (maybe later than Nim v1.0.6) (See also https://nim-lang.org/docs/nimc.html).
Before v1.0.6, you can use niml with compiler build with vmdef patched as follows
diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim
index 7a2bc1607..91706ae5d 100644
--- a/compiler/vmdef.nim
+++ b/compiler/vmdef.nim
@@ -17,7 +17,7 @@ const
byteExcess* = 128 # we use excess-K for immediates
wordExcess* = 32768
- MaxLoopIterations* = 3_000_000 # max iterations of all loops
+ MaxLoopIterations* = high(int) #3_000_000 # max iterations of all loops
improve some #25
It maybe solved when nim becomes version 1.0.0.
Hi, I'm encountering this issue using nim 1.0.6.
@samdmarshall thanks for your reporting. Could you share the code with the bug if you can?
oh, sorry, yeah - of course. i'll try to isolate into a stand-alone sample. do you want me posting here in this issue or as a new one?
Thanks! Either is fine. Link to #11 if you post as a new issue.
https://github.com/bung87/rust2nim I face this when compile entry file.
it's the first time I try to use a parser generator, I may doing something wrong, but this stop me get ing further information.
lexgen.nim
line:378
if toSeq(sTran.keys) == toSeq(tran.keys):
I modify to this , reduce the iterations, it seems under the compare calls the argument changes dynamically.
there's proc defaultAndOther
called by lexgen.nim(567, 33) convertToLexData
throw too many iterations
error .
@bung87 Thank you for your analysis!
if toSeq(sTran.keys) == toSeq(tran.keys): I modify to this , reduce the iterations, it seems under the compare calls the argument changes dynamically.
If you will create a new PR, I will merge this change after checking this has no unexpected effects.
You can avoid this error to use the new compiler option maxLoopIterationsVM:N
(maybe later than Nim v1.0.6) (See also https://nim-lang.org/docs/nimc.html).
I will create a PR later, merge if you think that's correct since I has no much knowledge in this domain. write a wrong grammar also will cause this?
I checked after modified test will not pass.
Sorry, @bung87. Your suggestion does not work expectedly.
toSeq(sTran.keys) == toSeq(tran.keys)
This returns always true and causes error in nimble test
.
(nim c -r tests/test_lexgen.nim
provides more information)
I did some refactoring in lexgen.nim in the #40. Check this if you are interested in what this part does.
@bung87
write a wrong grammar also will cause this?
No (as far as I know). This error is caused when the calculation needed to generate the lexer is too much. Without bug in the implementation, this generation does not cause infinite loops.
Thanks for your explaintion! then I feel fine with maxLoopIterationsVM
, from what I understand the lexer parser generate during compile time, that probably exceed the limit even code is fine, that sounds reasonable.
I just aware you removed the bug label, guess I can just try :P