Slightly better error message for invalid conversions in 'string.format'.
This commit is contained in:
Roberto Ierusalimschy
2018-12-27 14:19:53 -02:00
parent 662506476b
commit da37ac9c78
2 changed files with 2 additions and 3 deletions

View File

@@ -1180,8 +1180,7 @@ static int str_format (lua_State *L) {
break; break;
} }
default: { /* also treat cases 'pnLlh' */ default: { /* also treat cases 'pnLlh' */
return luaL_error(L, "invalid option '%%%c' to 'format'", return luaL_error(L, "invalid conversion '%s' to 'format'", form);
*(strfrmt - 1));
} }
} }
lua_assert(nb < MAX_ITEM); lua_assert(nb < MAX_ITEM);

View File

@@ -302,7 +302,7 @@ check("%100.3d", "too long")
check("%1"..aux..".3d", "too long") check("%1"..aux..".3d", "too long")
check("%1.100d", "too long") check("%1.100d", "too long")
check("%10.1"..aux.."004d", "too long") check("%10.1"..aux.."004d", "too long")
check("%t", "invalid option") check("%t", "invalid conversion")
check("%"..aux.."d", "repeated flags") check("%"..aux.."d", "repeated flags")
check("%d %d", "no value") check("%d %d", "no value")