mirror of
https://github.com/janet-lang/janet
synced 2025-10-16 08:17:41 +00:00
Add propagate function and opcode
This allows better stacktraces when manually intercepting signals to clean up resources. Also allows functionality from Common Lisp's unwind-protect, such as calling cleanup code while unwindinding the stack, restarting on certain signals, and just in general having more control over signal and signal propagation. Also fix a bug encountered while implementing with-resource in the compiler. Desturcturing arguments that were not the last argument would often result in bad code generation, as slots used to destructure the earlier arguments would invalidate the later parameters. This is fixed by allocating all named parameters before doing any destructuring.
This commit is contained in:
@@ -88,4 +88,21 @@
|
||||
(assert (peg/match p "abc") "complex peg grammar 1")
|
||||
(assert (peg/match p "[1 2 3 4]") "complex peg grammar 2")
|
||||
|
||||
#
|
||||
# fn compilation special
|
||||
#
|
||||
(defn myfn1 [[x y z] & more]
|
||||
more)
|
||||
(defn myfn2 [head & more]
|
||||
more)
|
||||
(assert (= (myfn1 [1 2 3] 4 5 6) (myfn2 [:a :b :c] 4 5 6)) "destructuring and varargs")
|
||||
|
||||
#
|
||||
# Test propagation of signals via fibers
|
||||
#
|
||||
|
||||
(def f (fiber/new (fn [] (error :abc) 1) :ei))
|
||||
(def res (resume f))
|
||||
(assert-error :abc (propagate res f) "propagate 1")
|
||||
|
||||
(end-suite)
|
||||
|
Reference in New Issue
Block a user