diff --git a/spec/declaration/record_spec.lua b/spec/declaration/record_spec.lua index 3c58abed7..993a4bb9b 100644 --- a/spec/declaration/record_spec.lua +++ b/spec/declaration/record_spec.lua @@ -86,7 +86,7 @@ for i, name in ipairs({"records", "arrayrecords"}) do parse: function(self: SLAXML, xml: string, anotherself: SLAXML) end - local myxml = io.open('my.xml'):read('*all') + local myxml = io.open('my.xml'):read('*all') as string SLAXML:parse(myxml, SLAXML) ]])) diff --git a/spec/stdlib/io_spec.lua b/spec/stdlib/io_spec.lua index d8d2bebd3..bcba4d979 100644 --- a/spec/stdlib/io_spec.lua +++ b/spec/stdlib/io_spec.lua @@ -47,7 +47,7 @@ describe("io", function() describe("read", function() it("accepts a union (#317)", util.check([[ - local function loadFile(textFile: string, amount: string | number): string, FILE + local function loadFile(textFile: string, amount: string | integer): string, FILE local file = io.open(textFile, "r") if not file then error("ftcsv: File not found at " .. textFile) end local lines: string diff --git a/tl.lua b/tl.lua index 747e8e137..f41a81f76 100644 --- a/tl.lua +++ b/tl.lua @@ -5229,7 +5229,7 @@ local function init_globals(lax) ["lines"] = a_type({ typename = "function", args = VARARG({ NOMINAL_FILE, a_type({ typename = "union", types = { STRING, NUMBER } }) }), rets = TUPLE({ a_type({ typename = "function", args = TUPLE({}), rets = VARARG({ STRING }) }), }), }), - ["read"] = a_type({ typename = "function", args = TUPLE({ NOMINAL_FILE, UNION({ STRING, NUMBER }) }), rets = TUPLE({ STRING, STRING }) }), + ["read"] = a_type({ typename = "function", args = VARARG({ NOMINAL_FILE, UNION({ STRING, INTEGER }) }), rets = VARARG({ UNION({ STRING, NUMBER }) }) }), ["seek"] = a_type({ typename = "function", args = TUPLE({ NOMINAL_FILE, OPT(STRING), OPT(NUMBER) }), rets = TUPLE({ INTEGER, STRING }) }), ["setvbuf"] = a_type({ typename = "function", args = TUPLE({ NOMINAL_FILE, STRING, OPT(NUMBER) }), rets = TUPLE({}) }), ["write"] = a_type({ typename = "function", args = VARARG({ NOMINAL_FILE, UNION({ STRING, NUMBER }) }), rets = TUPLE({ NOMINAL_FILE, STRING }) }), @@ -5371,7 +5371,7 @@ local function init_globals(lax) ["open"] = a_type({ typename = "function", args = TUPLE({ STRING, STRING }), rets = TUPLE({ NOMINAL_FILE, STRING }) }), ["output"] = a_type({ typename = "function", args = TUPLE({ OPT(UNION({ STRING, NOMINAL_FILE })) }), rets = TUPLE({ NOMINAL_FILE }) }), ["popen"] = a_type({ typename = "function", args = TUPLE({ STRING, STRING }), rets = TUPLE({ NOMINAL_FILE, STRING }) }), - ["read"] = a_type({ typename = "function", args = TUPLE({ UNION({ STRING, NUMBER }) }), rets = TUPLE({ STRING, STRING }) }), + ["read"] = a_type({ typename = "function", args = VARARG({ UNION({ STRING, INTEGER }) }), rets = VARARG({ UNION({ STRING, NUMBER }) }) }), ["stderr"] = NOMINAL_FILE, ["stdin"] = NOMINAL_FILE, ["stdout"] = NOMINAL_FILE, diff --git a/tl.tl b/tl.tl index 730712d24..74a5baf74 100644 --- a/tl.tl +++ b/tl.tl @@ -5229,7 +5229,7 @@ local function init_globals(lax: boolean): {string:Variable}, {string:Type} ["lines"] = a_type { typename = "function", args = VARARG { NOMINAL_FILE, a_type { typename = "union", types = { STRING, NUMBER } } }, rets = TUPLE { a_type { typename = "function", args = TUPLE {}, rets = VARARG { STRING } }, } }, - ["read"] = a_type { typename = "function", args = TUPLE { NOMINAL_FILE, UNION { STRING, NUMBER } }, rets = TUPLE { STRING, STRING } }, + ["read"] = a_type { typename = "function", args = VARARG { NOMINAL_FILE, UNION { STRING, INTEGER } }, rets = VARARG { UNION { STRING, NUMBER } } }, ["seek"] = a_type { typename = "function", args = TUPLE { NOMINAL_FILE, OPT(STRING), OPT(NUMBER) }, rets = TUPLE { INTEGER, STRING } }, ["setvbuf"] = a_type { typename = "function", args = TUPLE { NOMINAL_FILE, STRING, OPT(NUMBER) }, rets = TUPLE {} }, ["write"] = a_type { typename = "function", args = VARARG { NOMINAL_FILE, UNION { STRING, NUMBER } }, rets = TUPLE { NOMINAL_FILE, STRING } }, @@ -5371,7 +5371,7 @@ local function init_globals(lax: boolean): {string:Variable}, {string:Type} ["open"] = a_type { typename = "function", args = TUPLE { STRING, STRING }, rets = TUPLE { NOMINAL_FILE, STRING } }, ["output"] = a_type { typename = "function", args = TUPLE { OPT(UNION { STRING, NOMINAL_FILE }) }, rets = TUPLE { NOMINAL_FILE } }, ["popen"] = a_type { typename = "function", args = TUPLE { STRING, STRING }, rets = TUPLE { NOMINAL_FILE, STRING } }, - ["read"] = a_type { typename = "function", args = TUPLE { UNION { STRING, NUMBER } }, rets = TUPLE { STRING, STRING } }, + ["read"] = a_type { typename = "function", args = VARARG { UNION { STRING, INTEGER } }, rets = VARARG { UNION { STRING, NUMBER } } }, ["stderr"] = NOMINAL_FILE, ["stdin"] = NOMINAL_FILE, ["stdout"] = NOMINAL_FILE, @@ -10716,7 +10716,7 @@ end local function read_full_file(fd: FILE): string, string local bom = "\xEF\xBB\xBF" - local content, err = fd:read("*a") + local content, err = fd:read("*a") as (string, string) if content:sub(1, bom:len()) == bom then content = content:sub(bom:len() + 1) end