Skip to content

Binary operator "as" has weaker precedence than binary operator "<" #13081

Closed

Description

A simple example

enum Direction {
  North,
  East,
  South,
  West
}

fn main (){
  println!("{}", North as int < 2)
//Compiles fine with >, >=, <=, == and !=
//but with < I get
//test.rs:9:31: 9:32 error: expected type, found token LIT_INT_UNSUFFIXED(2i64)
//test.rs:9 println!("{}", North as int < 2)
//                                        ^             
} 

If I use parenthesis

println!("{}", (North as int) < 2)

It compiles.

This is related with issue #11962

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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