Skip to content

Does v2.0 do implicit Lua type casting for boolean truthy/falsy values? #169

@Luashine

Description

@Luashine

jassdoc/builtin-types.j

Lines 6 to 13 in 2062c72

/**
Booleans might be `true` or `false`, "common.j" variables `TRUE` and `FALSE` were added to allow you to use them, but it is not a good idea to do so. Using `true` is faster than getting a value of variable `TRUE`.
Comparision expresions `==`, `<=`, `<`, `>`, `>=`, `!=` return `boolean`.
Statements `if`, `elseif` and `exitwhen` take `boolean` as argument.
*/
type boolean extends void

jassdoc/common.j

Line 9565 in 4034ef5

native StringCase takes string source, boolean upper returns string

Currently (2.0.2.22761) if you run in Lua: StringCase("a", "wow"), it'll interpret "wow" as a truthy boolean. In my memory, I think it was strict about booleans and numbers before? and would've rejected this, requiring a real boolean true/false. I'd like to confirm against 1.32, 1.36 and add this note to builtin-types.j

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs legacy testFor longitudinal tests across old/new versions

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions