From ca0cf6232d3cf672ca9abf06f0c64c5584baac9d Mon Sep 17 00:00:00 2001 From: Fleutot Date: Wed, 11 Dec 2013 18:13:34 +0100 Subject: Fixed an improper error message Forgot to check that type=="string" before doing pattern matching on a field content. Was triggered when version was provided as a string in a luarock. --- src/luarocks/type_check.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/luarocks/type_check.lua b/src/luarocks/type_check.lua index 5436bde6..a3d41efc 100644 --- a/src/luarocks/type_check.lua +++ b/src/luarocks/type_check.lua @@ -1,4 +1,3 @@ - --- Type-checking functions. -- Functions and definitions for doing a basic lint check on files -- loaded by LuaRocks. @@ -183,7 +182,9 @@ local function type_check_item(name, item, expected, context) return nil, "Type mismatch on field "..context..name..": expected a string" end if expected ~= "string" then - if not item:match("^"..expected.."$") then + if item_type ~= "string" then + return nil, "Type mismatch on field "..context..name..": expected a string, got a "..type(item) + elseif not item:match("^"..expected.."$") then return nil, "Type mismatch on field "..context..name..": invalid value "..item.." does not match '"..expected.."'" end end -- cgit v1.2.3-55-g6feb