[Commits] [wesnoth/wesnoth] e23ff7: Lua: Fix uses of `tostring` calls as LHSs to `or`
GitHub
noreply at github.com
Mon Dec 29 11:43:48 UTC 2014
Branch: refs/heads/master
Home: https://github.com/wesnoth/wesnoth
Commit: e23ff7009c6c2324c6f7827a713c8d4d43960f5a
https://github.com/wesnoth/wesnoth/commit/e23ff7009c6c2324c6f7827a713c8d4d43960f5a
Author: 8573 <8573dd at gmail.com>
Date: 2014-12-29 (Mon, 29 Dec 2014)
Changed paths:
M data/lua/wml-tags.lua
M data/lua/wml/items.lua
Log Message:
-----------
Lua: Fix uses of `tostring` calls as LHSs to `or`
This commit changes occurrences of the pattern `tostring(x) or y` to
`tostring(x or y)` in the following Lua scripts:
- `data/lua/wml-tags.lua`
- `data/lua/wml/items.lua`
`tostring(x) or y` is unlikely to do what the author intended (and is
pointless unless `x` is an object of a custom type with unusual
behavior), because `tostring` returns a string (`"false"` or `"nil"`)
if `x` is a falsy value (`false` or `nil`), and all strings are truthy
in Lua — thus, `tostring(x) or y` will (unless `x` is of a custom
type) *always* evaluate to `tostring(x)`, never to `y`.
`tostring(x or y)` should, I expect, give the intended behavior.
Commit: 332e64f945dadea0cd08da67fd4004dbda23a932
https://github.com/wesnoth/wesnoth/commit/332e64f945dadea0cd08da67fd4004dbda23a932
Author: Charles Dang <exodia339 at gmail.com>
Date: 2014-12-29 (Mon, 29 Dec 2014)
Changed paths:
M data/lua/wml-tags.lua
M data/lua/wml/items.lua
Log Message:
-----------
Merge pull request #353 from 8573/8573/fix/lua/tostring-calls-as-1st-operands-of-or-exprs/1
Lua: Fix uses of `tostring` calls as LHSs to `or`
Compare: https://github.com/wesnoth/wesnoth/compare/f8c811fa4f69...332e64f945da
More information about the Commits
mailing list