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

ICE with const-generic signature #885

Open
ranjitjhala opened this issue Nov 15, 2024 · 4 comments
Open

ICE with const-generic signature #885

ranjitjhala opened this issue Nov 15, 2024 · 4 comments

Comments

@ranjitjhala
Copy link
Contributor

The code below

#[flux::sig(fn (head: _, rows: _) -> usize)]
fn csv<const N: usize>(head: [&str; N], rows: &[[&str; N]]) -> usize {
    0
}

makes flux keel over with

 --> tests/tests/todo/boo.rs:2:4
  |
2 | fn csv<const N: usize>(head: [&str; N], rows: &[[&str; N]]) -> usize {
  |    ^^^
-Ztrack-diagnostics: created at compiler/rustc_passes/src/dead.rs:1114:18
  |
  = note: `#[warn(dead_code)]` on by default

thread 'rustc' panicked at crates/flux-fhir-analysis/src/conv/struct_compat.rs:526:22:
attempt to subtract with overflow
@nilehmann
Copy link
Member

This must be related to these changes #884. Struct compact requires some complicated de Bruijn index juggling

@ranjitjhala
Copy link
Contributor Author

@nilehmann any idea what is going on here? Seems like some glitch in adjust_bvars ?

@ranjitjhala
Copy link
Contributor Author

Looks like this works instead

#[flux::sig(fn (rows: &[_]))]
fn csv<const N: usize>(rows: &[[&str; N]]) {}

@nilehmann
Copy link
Member

nilehmann commented Nov 15, 2024

That code fills in holes by matching against the default signature. When we find a match, the hole and the matching type could be under a different number of binders so we try to adjust de Bruijn indices. It's a confusing computation and I just probably got it wrong.

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