Skip to content

Commit

Permalink
fix: Use annotated type when checking declaration (#4966)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves #4742

## Summary\*



## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
vezenovm authored May 2, 2024
1 parent 0154bde commit f7fa696
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion compiler/noirc_frontend/src/hir/type_check/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ impl<'interner> TypeChecker<'interner> {
if annotated_type.is_unsigned() {
self.lint_overflowing_uint(&rhs_expr, &annotated_type);
}
annotated_type
} else {
expr_type
}
expr_type
}

/// Check if an assignment is overflowing with respect to `annotated_type`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "slice_init_with_complex_type"
type = "bin"
authors = [""]
compiler_version = ">=0.28.0"

[dependencies]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
struct strct1 {
elem1: Field,
}

fn main() {
let var1: [[i32; 1]] = [[0]];
let var2: [[i32; 1]] = var1;

let var1: [(i32, u8)] = [(1, 2)];
let var2: [(i32, u8)] = var1;

let var3: [strct1] = [strct1 { elem1: 1321351 }];
let var4: [strct1] = var3;

let var1: [i32; 1] = [0];
let var2: [[i32; 1]] = [var1];
}
3 changes: 2 additions & 1 deletion tooling/debugger/ignored-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ no_predicates_numeric_generic_poseidon
regression_4709
fold_distinct_return
fold_fibonacci
fold_complex_outputs
fold_complex_outputs
slice_init_with_complex_type

0 comments on commit f7fa696

Please sign in to comment.