From 50c69b2c7e8aeca7a2d2ce7aed948a66ab4e57fa Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Sat, 9 Sep 2023 16:26:03 +0200 Subject: [PATCH] fix utf8.codes signature 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 } },