Skip to content

The redundant punctuation in "expected()" #1433

Closed

Description

@Fischer0522

The expected() function will format the message in accordance with format!("Expected: {expected}, found: {found}"). However, when expected() is called by parse_prefix() at line 1254 in mod.rs, the parameter is "an expression:". Consequently, the formatted message is "Expected: an expression:, found: EOF". The ":," appears redundant.

Related code:

    /// Report `found` was encountered instead of `expected`
    pub fn expected<T>(&self, expected: &str, found: TokenWithLocation) -> Result<T, ParserError> {
        parser_err!(
            format!("Expected: {expected}, found: {found}"),
            found.location
        )
    }

// in parse_prefix()
            _ => self.expected("an expression:", next_token),

Activity

  1. Fischer0522 commented on Sep 19, 2024

    @Fischer0522
    ContributorAuthor

    Perhaps “Expected: an expression, found: EOF” is a more appropriate format. Please review it @alamb

  2. git-hulk commented on Sep 19, 2024

    @git-hulk
    Member

    It should be good to remove the redundant :. Also, maybe you can check if other places which use expect have similar issues.

  3. Fischer0522 commented on Sep 19, 2024

    @Fischer0522
    ContributorAuthor

    It should be good to remove the redundant :. Also, maybe you can check if other places which use expect have similar issues.

    I have checked all places that use expect. This is the only place where this problem occurs. please check this pr #1434

  4. git-hulk commented on Sep 23, 2024

    @git-hulk
    Member

    @Fischer0522 This issue can be closed now.

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