You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I attempted to use penlight's pl.pretty.dump() for a quick and
dirty document format for a simple utility. Its one-argument form
where the first parameter is the table to dump to stdout works
exactly as documented. Its two-argument form where the second
argument is the name of a file fails with a mysterious error:
E:...>lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require 'pl.pretty'
> pl.pretty.dump({}, "test.txt")
utils.assert_string: argument 2 expected a 'string', got a 'table'
stack traceback:
stdin:1: in main chunk
[C]: ?
E:...>
Note that the message appears to blame argument 2 of my call to pl.pretty.dump() for being a table, but it is obviously not a
table. The issue is that the implementation of dump() leverages pl.util.writefile(), but doesn't pass the table through pl.pretty.write() to make it into a pretty string first. This is
confounded by the (otherwise rational) decision to make all stack
traces start from the user's call site.
At line 160 of pl/pretty.lua, change:
- return utils.raise(utils.writefile((select(1,...)),t))
+ return utils.raise(utils.writefile((select(1,...)),write(t)))
The text was updated successfully, but these errors were encountered:
I attempted to use penlight's
pl.pretty.dump()
for a quick anddirty document format for a simple utility. Its one-argument form
where the first parameter is the table to dump to stdout works
exactly as documented. Its two-argument form where the second
argument is the name of a file fails with a mysterious error:
Note that the message appears to blame argument 2 of my call to
pl.pretty.dump()
for being a table, but it is obviously not atable. The issue is that the implementation of
dump()
leveragespl.util.writefile()
, but doesn't pass the table throughpl.pretty.write()
to make it into a pretty string first. This isconfounded by the (otherwise rational) decision to make all stack
traces start from the user's call site.
At
line 160
ofpl/pretty.lua
, change:- return utils.raise(utils.writefile((select(1,...)),t))
+ return utils.raise(utils.writefile((select(1,...)),write(t)))
The text was updated successfully, but these errors were encountered: