@@ -291,17 +291,39 @@ func TestPCall(t *testing.T) {
291291	}))
292292	errorIfFalse (t , strings .Contains (err .Error (), "by handler" ), "" )
293293
294+ 	L .Push (L .GetGlobal ("f1" ))
294295	err  =  L .PCall (0 , 0 , L .NewFunction (func (L  * LState ) int  {
295296		L .RaiseError ("error!" )
296297		return  1 
297298	}))
298299	errorIfFalse (t , strings .Contains (err .Error (), "error!" ), "" )
299300
301+ 	L .Push (L .GetGlobal ("f1" ))
300302	err  =  L .PCall (0 , 0 , L .NewFunction (func (L  * LState ) int  {
301303		panic ("panicc!" )
302304		return  1 
303305	}))
304306	errorIfFalse (t , strings .Contains (err .Error (), "panicc!" ), "" )
307+ 
308+ 	// Issue #452, expected to be revert back to previous call stack after any error. 
309+ 	currentFrame , currentTop , currentSp  :=  L .currentFrame , L .GetTop (), L .stack .Sp ()
310+ 	L .Push (L .GetGlobal ("f1" ))
311+ 	err  =  L .PCall (0 , 0 , nil )
312+ 	errorIfFalse (t , err  !=  nil , "" )
313+ 	errorIfFalse (t , L .currentFrame  ==  currentFrame , "" )
314+ 	errorIfFalse (t , L .GetTop () ==  currentTop , "" )
315+ 	errorIfFalse (t , L .stack .Sp () ==  currentSp , "" )
316+ 
317+ 	currentFrame , currentTop , currentSp  =  L .currentFrame , L .GetTop (), L .stack .Sp ()
318+ 	L .Push (L .GetGlobal ("f1" ))
319+ 	err  =  L .PCall (0 , 0 , L .NewFunction (func (L  * LState ) int  {
320+ 		L .RaiseError ("error!" )
321+ 		return  1 
322+ 	}))
323+ 	errorIfFalse (t , err  !=  nil , "" )
324+ 	errorIfFalse (t , L .currentFrame  ==  currentFrame , "" )
325+ 	errorIfFalse (t , L .GetTop () ==  currentTop , "" )
326+ 	errorIfFalse (t , L .stack .Sp () ==  currentSp , "" )
305327}
306328
307329func  TestCoroutineApi1 (t  * testing.T ) {
0 commit comments