Skip to content

Commit

Permalink
fix: Methods called after being passed through a generic type were no…
Browse files Browse the repository at this point in the history
…t being detected (#1785)

* add follow-bindings method

* add regression test

* delete contents of Prover.toml

* chain call onto check_expression

* use underscore
  • Loading branch information
kevaundray authored Jun 21, 2023
1 parent 4293b15 commit e560cd2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use dep::std;
struct Item {
id: Field,
}

impl Item {
fn log(self) {
let id = self.id;
std::println(id);
}
}

fn create<V>(something: V) -> V {
something
}

fn main() {
let a = Item { id: 1 };
let b = create(a);
let _id = b.id;
// Regression for: cannot find this method
b.log();
}
2 changes: 1 addition & 1 deletion crates/noirc_frontend/src/hir/type_check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<'interner> TypeChecker<'interner> {
self.bind_function_type(function, args, span)
}
HirExpression::MethodCall(method_call) => {
let object_type = self.check_expression(&method_call.object);
let object_type = self.check_expression(&method_call.object).follow_bindings();
let method_name = method_call.method.0.contents.as_str();
match self.lookup_method(object_type.clone(), method_name, expr_id) {
Some(method_id) => {
Expand Down

0 comments on commit e560cd2

Please sign in to comment.