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

Fix impl self node order dependency pass key collision issue. #6407

Merged
merged 4 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sway-core/src/semantic_analysis/node_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ fn decl_name(engines: &Engines, decl: &Declaration) -> Option<DependentSymbol> {
}
})
.collect::<Vec<String>>()
.join(""),
.join(","),
)
} else if decl.trait_name.prefixes.is_empty() {
impl_sym(
Expand All @@ -986,7 +986,7 @@ fn decl_name(engines: &Engines, decl: &Declaration) -> Option<DependentSymbol> {
}
})
.collect::<Vec<_>>()
.join(""),
.join(","),
)
} else {
None
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
out
target
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[package]]
name = "core"
source = "path+from-root-0C133FB33C94FAC1"

[[package]]
name = "impl_self_dependency_order_conflict"
source = "member"
dependencies = ["std"]

[[package]]
name = "std"
source = "path+from-root-0C133FB33C94FAC1"
dependencies = ["core"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[project]
entry = "main.sw"
authors = ["Fuel Labs <contact@fuel.sh>"]
license = "Apache-2.0"
name = "impl_self_dependency_order_conflict"

[dependencies]
std = { path = "../../../reduced_std_libs/sway-lib-std-assert" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library;

pub fn foo() -> u32 {
1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
library;

mod foo;
use foo::*;

struct S {}

impl S { //dependency of this impl is overwritten by the next impl
fn a() -> u32 { foo() }
fn b() {}
}

impl S { //this will overwrite the dependency for the previous impl
fn ab() {}
}

fn foo() -> u32 {
2
}

fn main() {}

#[test]
fn test() {
assert_eq(2, S::a());
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
category = "unit_tests_pass"

Loading