Skip to content

js_parse_* functions should use PF_ flags, not booleans #864

Closed
@bnoordhuis

Description

@bnoordhuis

General pattern, specific example:

if (js_parse_var(s, true, tok, true))
    goto fail;

Definition:

static __exception int js_parse_var(JSParseState *s, int parse_flags, int tok,
                                    bool export_flag);

Ergo, the call site should look like this:

if (js_parse_var(s, PF_IN_ACCEPTED, tok, /*export_flag*/true))
    goto fail;

It works okay because PF_IN_ACCEPTED == 1 and true == 1 but it's confusing.

In the particular case of js_parse_var, that export_flag boolean could maybe be a PF_ flag instead. On the other hand, you could argue module exports aren't a parser concern and I wouldn't disagree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions