From ef508462b8caeb763379ce8a23a271b4928ffcf4 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 14 Aug 2019 01:43:04 -0400 Subject: [PATCH] shims: Add a better error message when mouse.screen is called too early. --- tests/examples/shims/mouse.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/examples/shims/mouse.lua b/tests/examples/shims/mouse.lua index 13867f4d..f6fd4ff3 100644 --- a/tests/examples/shims/mouse.lua +++ b/tests/examples/shims/mouse.lua @@ -61,7 +61,14 @@ return setmetatable(mouse, { if forced_screen and screen._deleted[forced_screen] then forced_screen = nil end - return screen[1] + + -- Using capi.mouse.screen is *not* supported when there is zero + -- screen. Nearly all the code uses `mouse.screen` as its ultimate + -- fallback. Having no screens is tolerated during early + -- initialization and that's it. + return screen.count() > 0 and screen[1] or assert( + false, "Calling `mouse.screen` without screens isn't supported" + ) end local h = rawget(mouse,"_i_handler") if h then