diff --git a/lib/Minilisp.pm b/lib/Minilisp.pm index 57c5f4b..e01a4ba 100644 --- a/lib/Minilisp.pm +++ b/lib/Minilisp.pm @@ -960,7 +960,7 @@ sub macro_do { slurp_token($ts, RPAREN, "Expected ) after resultform"); - my $body = macro_progn($ts); + my $body = macro_tagbody($ts); return create_block("nil", sub { my $octx = shift; diff --git a/t/do.t b/t/do.t index c09bd9f..fc322eb 100644 --- a/t/do.t +++ b/t/do.t @@ -1,4 +1,6 @@ -(plan 3) +(plan 4) + +(defun nop () nil) (expect "do - simple example" (equal (do ((n 1)) (t n)) 1)) @@ -20,3 +22,15 @@ (do () (t) (return 'fail)) 'ok))) + +(expect "do - implicit tagbody" + (equal 'ok + (catch 'test + (do ((n 0 (+ 1 n))) ((> n 0)) + (nop) + (nop) + (go end) + middle + (throw 'test 'fail) + end) + 'ok)))