Skip to content

Formatter definition is recursive #250

@abacabadabacaba

Description

@abacabadabacaba

What is the issue with the Console Standard?

The definition of Formatter is recursive: it substitutes the first format specifier and calls itself recursively on the result. This leads to a problem: if the result of substitution itself contains format specifiers, they are also processed.

For example, the developer may assume that the call console.log("(%s, %s)", a, b) would work similarly to console.log(`(${a}, ${b})`). But there is a difference: if (the string form of) a contains a format specifier, it will be applied to b, which is probably not what the developer expected.

This recursive definition also doesn't play well with substituting %% with % (which this specification doesn't prescribe, but which both Chrome and Firefox do).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions