From ed2b38952ab1b226a5d2b1cc8adf82793baa7b9b Mon Sep 17 00:00:00 2001 From: Jesse van Herk Date: Tue, 1 Jul 2014 11:38:07 -0600 Subject: [PATCH] Add assertions for : calls, avoid bad recursion --- gamestate.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gamestate.lua b/gamestate.lua index 854100c..0b3d6ec 100644 --- a/gamestate.lua +++ b/gamestate.lua @@ -36,6 +36,7 @@ function GS.new(t) return t or {} end -- constructor - deprecated! function GS.switch(to, ...) assert(to, "Missing argument: Gamestate to switch to") + assert( to ~= GS, "Can't call switch with colon operator" ) local pre = stack[#stack] ;(pre.leave or __NULL__)(pre) ;(to.init or __NULL__)(to) @@ -46,6 +47,7 @@ end function GS.push(to, ...) assert(to, "Missing argument: Gamestate to switch to") + assert( to ~= GS, "Can't call push with colon operator" ) local pre = stack[#stack] ;(to.init or __NULL__)(to) to.init = nil