From 02dae8bfb173ab45231dae9d71cd9b5d28f9952e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Perrad?= Date: Wed, 13 Sep 2023 23:15:32 +0200 Subject: [PATCH] fix utf8.codes signature (#696) the iterator returned by `utf8.codes` needs some arguments (when called outside a `for` loop) ``` $ cat codes.lua local s = "foo" local iter = utf8.codes(s) print(iter(s)) print(iter(s, 1)) $ ./tl run codes.lua 1 102 2 111 $ ./tl check codes.lua ======================================== 2 errors: codes.lua:3:11: wrong number of arguments (given 1, expects 0) codes.lua:4:11: wrong number of arguments (given 2, expects 0) ``` --- tl.lua | 2 +- tl.tl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tl.lua b/tl.lua index 3db88c27b..b34f4615e 100644 --- a/tl.lua +++ b/tl.lua @@ -5571,7 +5571,7 @@ local function init_globals(lax) ["charpattern"] = STRING, ["codepoint"] = a_type({ typename = "function", args = TUPLE({ STRING, OPT(NUMBER), OPT(NUMBER) }), rets = VARARG({ INTEGER }) }), ["codes"] = a_type({ typename = "function", args = TUPLE({ STRING }), rets = TUPLE({ - a_type({ typename = "function", args = TUPLE({}), rets = TUPLE({ NUMBER, NUMBER }) }), + a_type({ typename = "function", args = TUPLE({ STRING, OPT(NUMBER) }), rets = TUPLE({ NUMBER, NUMBER }) }), }), }), ["len"] = a_type({ typename = "function", args = TUPLE({ STRING, NUMBER, NUMBER }), rets = TUPLE({ INTEGER }) }), ["offset"] = a_type({ typename = "function", args = TUPLE({ STRING, NUMBER, NUMBER }), rets = TUPLE({ INTEGER }) }), diff --git a/tl.tl b/tl.tl index 2e79e1fd8..fdf537b75 100644 --- a/tl.tl +++ b/tl.tl @@ -5571,7 +5571,7 @@ local function init_globals(lax: boolean): {string:Variable}, {string:Type} ["charpattern"] = STRING, ["codepoint"] = a_type { typename = "function", args = TUPLE { STRING, OPT(NUMBER), OPT(NUMBER) }, rets = VARARG { INTEGER } }, ["codes"] = a_type { typename = "function", args = TUPLE { STRING }, rets = TUPLE { - a_type { typename = "function", args = TUPLE {}, rets = TUPLE { NUMBER, NUMBER } }, + a_type { typename = "function", args = TUPLE { STRING, OPT(NUMBER) }, rets = TUPLE { NUMBER, NUMBER } }, }, }, ["len"] = a_type { typename = "function", args = TUPLE { STRING, NUMBER, NUMBER }, rets = TUPLE { INTEGER } }, ["offset"] = a_type { typename = "function", args = TUPLE { STRING, NUMBER, NUMBER }, rets = TUPLE { INTEGER } },