Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix io.read & file:read signature #718

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/declaration/record_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]]))

Expand Down
2 changes: 1 addition & 1 deletion spec/stdlib/io_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) }),
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -10716,7 +10716,7 @@ end

local function read_full_file(fd: FILE): string, string
local bom <const> = "\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
Expand Down
Loading