Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails to parse multiple arithmetic operators without parentheses #143

Open
bblum opened this issue Apr 12, 2019 · 1 comment
Open

fails to parse multiple arithmetic operators without parentheses #143

bblum opened this issue Apr 12, 2019 · 1 comment

Comments

@bblum
Copy link

bblum commented Apr 12, 2019

10 #[mutate]
11 pub fn add_five(i: usize) -> usize {
12     i + 4 + 1
13 }

fails to cargo test with:

error: custom attribute panicked
   --> src/test.rs:10:1
    |
157 | #[mutate]
    | ^^^^^^^^^
    |
    = help: message: expected expression

error: aborting due to previous error

If you change the plus to a minus, it produces instead

error[E0308]: mismatched types
   --> src/test.rs:10:1
    |
157 | #[mutate]
    | ^^^^^^^^^ expected (), found usize
    |
    = note: expected type `()`
               found type `usize`

error[E0308]: mismatched types
   --> src/test.rs:10:1
    |
157 | #[mutate]
    | ^^^^^^^^^- help: try adding a semicolon: `;`
    | |
    | expected (), found usize
    |
    = note: expected type `()`
               found type `usize`

error[E0600]: cannot apply unary operator `-` to type `usize`
   --> src/test.rs:10:1
    |
157 | #[mutate]
    | ^^^^^^^^^ cannot apply unary operator `-`
    |
    = note: unsigned values cannot be negated

error: aborting due to 3 previous errors

With multiply as the second operation instead:

error[E0271]: type mismatch resolving `<i32 as mutagen::MulDiv>::Output == usize`
   --> src/test.rs:10:1
    |
157 | #[mutate]
    | ^^^^^^^^^ expected i32, found usize

error: aborting due to previous error
@bblum
Copy link
Author

bblum commented Apr 18, 2019

this one can be fixed by putting parens around the #left $op_found #right in the definition of fold_binary!, although i'm honestly not sure why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant