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

Support if/else within if condition in condval! #1

Open
nvzqz opened this issue Aug 20, 2023 · 0 comments
Open

Support if/else within if condition in condval! #1

nvzqz opened this issue Aug 20, 2023 · 0 comments
Labels
good first issue Good for newcomers

Comments

@nvzqz
Copy link
Owner

nvzqz commented Aug 20, 2023

The following Rust statement works:

let x = if if true { true } else { false } { "a" } else { "b" };

But the same wrapped in condval! does not parse:

error: expected `{`, found `}`
 --> src/main.rs:4:13
  |
4 |     let x = condval!(if if true { true } else { false } { "a" } else { "b" });
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{`
  |
note: the `if` expression is missing a block after this condition
 --> src/main.rs:4:28
  |
4 |     let x = condval!(if if true { true } else { false } { "a" } else { "b" });
  |                            ^^^^
  = note: this error originates in the macro `$crate::__condval_parser` which comes from the expansion of the macro `condval` (in Nightly builds, run with -Z macro-backtrace for more info)

error: no rules expected the token `{`
   --> src/main.rs:4:47
    |
4   |     let x = condval!(if if true { true } else { false } { "a" } else { "b" });
    |                                               ^ no rules expected this token in macro call
    |
note: while trying to match `if`
   --> condtype/src/lib.rs:212:6
    |
212 |     (if let $pat:pat = $input:block $then:block else $else:block) => {
    |      ^^

error: could not compile `condtype` (bin "condtype") due to 2 previous errors
@nvzqz nvzqz added the good first issue Good for newcomers label Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant