refaktor / rye

homoiconic dynamic programming language with some new ideas
https://ryelang.org
Apache License 2.0
462 stars 22 forks source link

Panic Using op-words or pipe-words with no-argument functions #271

Closed cwarden closed 3 months ago

cwarden commented 3 months ago

rye panics if trying to call a no-argument function using op-words or pipewords:

x> y: does { }
[Function(0)]
x> .y
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/refaktor/rye/env.TSeries.Get(...)
        /home/cwarden/git/rye/env/series.go:94
github.com/refaktor/rye/evaldo.CallFunction({0x0, {{{0xc8dce0, 0x0, 0x0}, 0x0}, 0x0}, {{{0xc8dce0, 0x0, 0x0}, 0x0}, ...}, ...}, ...)
        /home/cwarden/git/rye/evaldo/evaldo.go:609 +0x9af
github.com/refaktor/rye/evaldo.EvalObject(0xc0000bbd40, {0x95c9c0, 0xc000409580}, {0x95c9c0, 0xc000409580}, 0x0, 0x0, 0x0, {0x0, 0x0})
        /home/cwarden/git/rye/evaldo/evaldo.go:521 +0x245
github.com/refaktor/rye/evaldo.EvalWord(0xc0000bbd40, {0x95c330, 0xc000380550}, {0x95c9c0, 0xc000409580}, 0x0, 0x0)
        /home/cwarden/git/rye/evaldo/evaldo.go:476 +0x3a6
github.com/refaktor/rye/evaldo.MaybeEvalOpwordOnRight({0x95cbf0?, 0xc000380540?}, 0xc0000bbd40, 0x0)
        /home/cwarden/git/rye/evaldo/evaldo.go:252 +0x6c9
github.com/refaktor/rye/evaldo.EvalExpressionInj(0xc8dce0?, {0x95c9c0?, 0xc000409580?}, 0x1)
        /home/cwarden/git/rye/evaldo/evaldo.go:196 +0xb2
github.com/refaktor/rye/evaldo.EvalBlockInj(0xc000380418?, {0x95c9c0, 0xc000409580}, 0x18?)
        /home/cwarden/git/rye/evaldo/evaldo.go:81 +0x4f
github.com/refaktor/rye/evaldo.(*Repl).evalLine(0xc000304000, 0xc0000bbd40, {0xc000380418, 0x2})
        /home/cwarden/git/rye/evaldo/repl.go:208 +0x487
github.com/refaktor/rye/evaldo.(*Repl).recieveLine(0xc000304000, {0xc000380418?, 0xc000380418?})
        /home/cwarden/git/rye/evaldo/repl.go:173 +0x2d
github.com/refaktor/rye/util.(*MLState).MicroPrompt(0xc000300060, {0x89c64b, 0x3}, {0x0, 0x0}, 0x0?)
        /home/cwarden/git/rye/util/microliner.go:665 +0x3da
github.com/refaktor/rye/evaldo.DoRyeRepl(0xc0000bbd40, {0x89c380, 0x2}, 0x1)
        /home/cwarden/git/rye/evaldo/repl.go:347 +0x45f
github.com/refaktor/rye/runner.main_rye_repl({0xc0000cc000?, 0xc000024170?}, {0x100470b80?, 0xc0000061c0?}, 0x1, 0x0, {0x89c380, 0x2}, 0x8dae70)
        /home/cwarden/git/rye/runner/runner.go:545 +0x33f
github.com/refaktor/rye/runner.DoMain(0x8dae70)
        /home/cwarden/git/rye/runner/runner.go:88 +0x11b
main.main()
        /home/cwarden/git/rye/main.go:36 +0x1a
refaktor commented 3 months ago

Uh, thank you for noticing and reporting! It seems I've never done this so far :) ... I will fix it.

refaktor commented 3 months ago

Fixed with https://github.com/refaktor/rye/pull/274. Thanks for reporting it!