Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf committed Nov 23, 2022
1 parent 4698afe commit 029e423
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
6 changes: 5 additions & 1 deletion crates/analyzer/src/traversal/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ fn expr_call_path<T: std::fmt::Display>(
generic_args: &Option<Node<Vec<fe::GenericArg>>>,
args: &Node<Vec<Node<fe::CallArg>>>,
) -> Result<(ExpressionAttributes, CallType), FatalError> {
match context.resolve_any_path(path) {
match context.resolve_visible_path(path) {
Some(named_thing) => {
check_visibility(context, &named_thing, func.span);
validate_has_no_conflicting_trait_in_scope(context, &named_thing, path, func)?;
Expand Down Expand Up @@ -1107,6 +1107,10 @@ fn expr_call_trait_associated_function<T: std::fmt::Display>(
}
}

// At this point, we will have an error so we run `resolve_path` to register any errors that we
// did not report yet
context.resolve_path(path, func.span)?;

Err(FatalError::new(context.error(
"unresolved path item",
func.span,
Expand Down
6 changes: 3 additions & 3 deletions crates/analyzer/tests/snapshots/errors__bad_ingot.snap
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ error: the struct `Foo` is private
= `Foo` can only be used within `foo`
= Hint: use `pub` to make `Foo` visible from outside of `foo`

error: incorrect type for `Foo` argument `my_num`
┌─ compile_errors/bad_ingot/src/main.fe:8:33
error: unresolved path item
┌─ compile_errors/bad_ingot/src/main.fe:8:16
8return foo::Foo(my_num: true)
^^^^ this has type `bool`; expected type `u256`
^^^^^^^^ not found


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub struct MyS {
fn x() -> u256 {
return 10
}
}
17 changes: 17 additions & 0 deletions crates/test-files/fixtures/ingots/trait_no_ambiguity/src/main.fe
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use foo::MyS

trait Trait {
fn x() -> u256;
}

impl Trait for MyS {
fn x() -> u256 {
return 10
}
}

contract Foo {
pub fn main() -> u256 {
return MyS::x()
}
}
7 changes: 7 additions & 0 deletions crates/tests/src/ingots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ fn test_ingot_with_visibility() {
})
}

#[test]
fn test_trait_no_ambiguity() {
with_executor(&|mut executor| {
let _harness = deploy_ingot(&mut executor, "trait_no_ambiguity", "Foo", &[]);
})
}

#[test]
fn test_ingot_pub_contract() {
with_executor(&|mut executor| {
Expand Down

0 comments on commit 029e423

Please sign in to comment.