diff --git a/_glua-tests/issues.lua b/_glua-tests/issues.lua index 514d0b7a..013dbc05 100644 --- a/_glua-tests/issues.lua +++ b/_glua-tests/issues.lua @@ -457,3 +457,13 @@ function test() assert(c == 1) assert(type(c) == "number") end + +-- issue #455 +function test() + local path = "." + local fd, _, code = io.open(path, "r") + assert(fd ~= nil) + local _, _, ecode = fd:read(1) + assert(ecode == 1) +end +test() diff --git a/iolib.go b/iolib.go index b59e82b2..e5c49f5f 100644 --- a/iolib.go +++ b/iolib.go @@ -404,10 +404,10 @@ normalreturn: return L.GetTop() - top errreturn: - L.RaiseError(err.Error()) - //L.Push(LNil) - //L.Push(LString(err.Error())) - return 2 + L.Push(LNil) + L.Push(LString(err.Error())) + L.Push(LNumber(1)) // C-Lua compatibility: Original Lua pushes errno to the stack + return 3 } var fileSeekOptions = []string{"set", "cur", "end"}