gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Privacy reporter cannot check resolved inferred types

Open CohenArthur opened this issue 3 years ago • 1 comments

fn main() {
    let arr0: [i32; 5] = [1, 2, 3, 4, 5];
    let arr1: [i32; 5] = [1, 2, 3, 4, 5];
    let arr2: [i32; 5] = [1, 2, 3, 4, 5];
    let arr3: [_; 5] = [1, 2, 3, 4, 5];
}

I expected to see this happen: No issues, since the array's element type (i32) gets checked correctly in the first 3 arrays and is resolved properly from the inference in the last one:

rust1: note: [0x5df8310] ARRAY:[i32:CAPACITY]:(Ref: 24 TyRef: 24[]):bounds:[]
rust1: note: [0x5df8230] Int:i32:(Ref: 22 TyRef: 8[8,95,]):bounds:[]
rust1: note: ARTHUR: use_id = 8
rust1: note: ARTHUR: resolved_id = 104
rust1: note: [0x5e02370] ARRAY:[i32:CAPACITY]:(Ref: 36 TyRef: 36[]):bounds:[]
rust1: note: [0x5e02290] Int:i32:(Ref: 34 TyRef: 8[8,132,]):bounds:[]
rust1: note: ARTHUR: use_id = 24
rust1: note: ARTHUR: resolved_id = 104
rust1: note: [0x5e0c400] ARRAY:[i32:CAPACITY]:(Ref: 48 TyRef: 48[]):bounds:[]
rust1: note: [0x5e0c320] Int:i32:(Ref: 46 TyRef: 8[8,169,]):bounds:[]
rust1: note: ARTHUR: use_id = 40
rust1: note: ARTHUR: resolved_id = 104
rust1: note: [0x5e164c0] ARRAY:[i32:CAPACITY]:(Ref: 59 TyRef: 59[]):bounds:[]
rust1: note: [0x5e19f00] Int:i32:(Ref: 57 TyRef: 8[8,57,60,61,62,63,64,181,182,185,190,197,206,218,219,]):bounds:[]
rust1: note: ARTHUR: use_id = 55
// assertion that this can get looked-up triggers here

Instead, this happened: Lookup failure when using resolver.lookup_type() with the proper use_id (55)

Meta

  • What version of Rust GCC were you using, git sha if possible

bc9340c21bbdbc45c9daa637617e9e9c9306011b

CohenArthur avatar May 19 '22 10:05 CohenArthur

This is a great bug to find because there are two ways we get inference variables one where we implicitly create them with a unique id and ones like this using '_' which should really have the same id as the place it was referenced.

I think the issue here will be in the rust-tyty-rules for unification of inference variables its probably taking the id of the first element in the array

philberty avatar May 19 '22 10:05 philberty

@CohenArthur i would be interested if you can retest this once https://github.com/Rust-GCC/gccrs/pull/1545 is merged. It may not fix all of the issues but I would imagine its a lot better

philberty avatar Sep 27 '22 11:09 philberty

@philberty compiler explorer seems to indicate that this was fixed

powerboat9 avatar Aug 20 '23 14:08 powerboat9

Yep, all fixed now. Will add a testcase in a PR to close this out

CohenArthur avatar Aug 21 '23 14:08 CohenArthur