Skip to content

Commit

Permalink
fix utf8.codes signature
Browse files Browse the repository at this point in the history
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)
```
  • Loading branch information
fperrad committed Sep 9, 2023
1 parent e29e29b commit 50c69b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) }),
Expand Down
2 changes: 1 addition & 1 deletion tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
Expand Down

0 comments on commit 50c69b2

Please sign in to comment.