bichanna / slap

🖐 A dynamically- and strongly-typed, object-oriented programming language
https://bichanna.github.io/slap/
MIT License
33 stars 0 forks source link

Call-limit-reached-error not handled #35

Closed bichanna closed 2 years ago

bichanna commented 2 years ago

code:

define func() { func(); }
func();

error:

Traceback (most recent call last)
/Users/nobu/WorkSpace/Nim/SLAP/src/main.nim(86) main
/Users/nobu/WorkSpace/Nim/SLAP/src/main.nim(42) runFile
/Users/nobu/WorkSpace/Nim/SLAP/src/main.nim(36) execute
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(528) interpret
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
(1874 calls omitted) ...
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(45) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(432) executeBlock
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(410) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(413) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(106) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(221) eval
/Users/nobu/WorkSpace/Nim/SLAP/src/interpreter.nim(41) :anonymous
/Users/nobu/WorkSpace/Nim/SLAP/src/env.nim(20) newEnv
/usr/local/Cellar/nim/1.6.2/nim/lib/pure/collections/tableimpl.nim(168) initTable
/usr/local/Cellar/nim/1.6.2/nim/lib/system/gc.nim(494) newSeq
/usr/local/Cellar/nim/1.6.2/nim/lib/system/gc.nim(486) newObj
/usr/local/Cellar/nim/1.6.2/nim/lib/system/alloc.nim(762) rawAlloc
/usr/local/Cellar/nim/1.6.2/nim/lib/system/alloc.nim(635) getSmallChunk
/usr/local/Cellar/nim/1.6.2/nim/lib/system/alloc.nim(606) getBigChunk
/usr/local/Cellar/nim/1.6.2/nim/lib/system/alloc.nim(548) splitChunk
/usr/local/Cellar/nim/1.6.2/nim/lib/system/alloc.nim(543) splitChunk2
/usr/local/Cellar/nim/1.6.2/nim/lib/system/alloc.nim(527) updatePrevSize
/usr/local/Cellar/nim/1.6.2/nim/lib/system/alloc.nim(492) isAccessible
/usr/local/Cellar/nim/1.6.2/nim/lib/system/alloc.nim pageIndex
Error: call depth limit reached in a debug build (2000 function calls). You can change it with -d:nimCallDepthLimit=<int> but really try to avoid deep recursions instead.
bichanna commented 2 years ago

With production SLAP, error changes to zsh: segmentation fault slap tests/limit/func\(func\(func\(\)\)\).slap.

GalaxianMonster commented 2 years ago

(I might be wrong) Debug build can contain some checks like call limit check while for Release build it might have no checks which means the call stack can be full which can cause a segmentation fault(It happens also in a C program)

GalaxianMonster commented 2 years ago

As said by the error, you should try not using recursions too much.

bichanna commented 2 years ago

Do you know how I can handle that? How can I have a check for that error? Can I handle this with something like a try-except statement?

bichanna commented 2 years ago

And I think, after fixing this bug, I will release the 0.0.3 version.

GalaxianMonster commented 2 years ago

I guess you need to limit recursion depth just like python does?