Skip to content

Parsing inconsistencies with semi-statements in expressions #29071

Closed

Description

@nagisa
    x = if true {
        10u32
    } else {
        20u32
    } as ()

parses as

    x = (if true {
        10u32
    } else {
        20u32
    } as ())

but

    if true {
        10u32
    } else {
        20u32
    } as ()

parses as

    if true {
        10u32
    } else {
        20u32
    }; 
    as ()

Activity

  1. nagisa commented on Oct 15, 2015

    @nagisa
    MemberAuthor

    This might showcase it better:

        x&if true {
            10u32
        } else {
            20u32
        }&x

    parsed as

        (x & if true {
            10u32
        } else {
            20u32
        } & x)

    but

        if true {
            10u32
        } else {
            20u32
        }&x

    is parsed as

        if true {
            10u32
        } else {
            20u32
        };
        &x

    which is completely different thing.

  2. nagisa commented on Oct 15, 2015

    @nagisa
    MemberAuthor

    Fixing this, would be a breaking change, but we at least need to ensure we have a test for this.

  3. arielb1 commented on Oct 15, 2015

    @arielb1
    Contributor

    @nagisa

    This looks like a consequence of "semicolon insertion" (the stmt: block_expr rule) being eager.

  4. added a commit that references this issue on Oct 27, 2015
  5. added a commit that references this issue on Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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