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

gccrs incorrectly parses a fake turbofish operator #3388

Open
1 task
liamnaddell opened this issue Jan 23, 2025 · 1 comment
Open
1 task

gccrs incorrectly parses a fake turbofish operator #3388

liamnaddell opened this issue Jan 23, 2025 · 1 comment

Comments

@liamnaddell
Copy link
Contributor

liamnaddell commented Jan 23, 2025

Summary

not<true>(); should actually be written as not::<true>();, i.e. a turbofish operator. It seems though that this survives the parsing phase.

Reproducer

I tried this code:

fn not<const A: bool>() {
    let _ = if A
        { "A" }
    else
        { "B" }
    ;
}

fn main() {
    not<true>();
}

Does the code make use of any (1.49) nightly feature ?

  • Nightly

Godbolt link

No response

Actual behavior

TRS-E14 cgen $ gccrs main.rs
main.rs:2:16: error: Cannot find path ‘A’ in this scope [E0433]
    2 |     let _ = if A
      |                ^

Expected behavior

TRS-E14 cgen :( $ rustc main.rs
error: comparison operators cannot be chained
  --> main.rs:10:8
   |
10 |     not<true>();
   |        ^    ^
   |

GCC Version

b87fd67

@powerboat9
Copy link
Contributor

I've reduced the testcase to this, which only errors with rustc

#[cfg(foo)]
fn foo() {
    not<true>();
}

fn main() {}

It does look like rustc has a parse-time check for chained comparisons, while we only catch it incidentally at typechecking

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

2 participants