wesnoth/wesnoth — pull request #353 by 8573 (2014-12-29 10:24:27+00:00)
Title: 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.