# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1521239425 0
# Node ID b03c7884fadefbad6614c39281b3999ee8839958
# Parent  9f6ab206d7411ac90ea74eff9e6a7c2d70d38b5d
util.async: You can never have too many asserts!

diff -r 9f6ab206d741 -r b03c7884fade util/async.lua
--- a/util/async.lua	Fri Mar 16 22:26:15 2018 +0000
+++ b/util/async.lua	Fri Mar 16 22:30:25 2018 +0000
@@ -23,6 +23,8 @@
 		local level = 0;
 		while debug.getinfo(thread, level, "") do level = level + 1; end
 		ok, runner = debug.getlocal(thread, level-1, 1);
+		assert(ok == "self", "unexpected async state: variable mismatch");
+		assert(runner.thread == thread, "unexpected async state: thread mismatch");
 		local error_handler = runner.watchers.error;
 		if error_handler then error_handler(runner, debug.traceback(thread, err)); end
 		local ready_handler = runner.watchers.ready;