Skip to content

Commit

Permalink
Search all namespaces for implemented traits, not just the local one (#…
Browse files Browse the repository at this point in the history
…532)

* Search all namespaces for implemented traits, not just the local one

* add json abi oracle

* fix oracle...
  • Loading branch information
sezna authored Dec 29, 2021
1 parent a38a89a commit 4038415
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 35 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docstrings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "docstrings"
version = "0.1.6"
version = "0.1.7"
edition = "2021"
publish = false

Expand Down
12 changes: 6 additions & 6 deletions forc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "forc"
version = "0.1.6"
version = "0.1.7"
authors = ["Fuel Labs <[email protected]>"]
edition = "2018"
homepage = "https://fuel.network/"
Expand Down Expand Up @@ -28,11 +28,11 @@ serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0.73"
source-span = "2.4"
structopt = "0.3"
sway-core = { version = "0.1.6", path = "../sway-core" }
sway-fmt = { version = "0.1.6", path = "../sway-fmt" }
sway-server = { version = "0.1.6", path = "../sway-server" }
sway-utils = { version = "0.1.6", path = "../sway-utils" }
sway-types = { version = "0.1.6", path = "../sway-types" }
sway-core = { version = "0.1.7", path = "../sway-core" }
sway-fmt = { version = "0.1.7", path = "../sway-fmt" }
sway-server = { version = "0.1.7", path = "../sway-server" }
sway-utils = { version = "0.1.7", path = "../sway-utils" }
sway-types = { version = "0.1.7", path = "../sway-types" }
tar = "0.4.35"
term-table = "1.3"
termcolor = "1.1"
Expand Down
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "parser"
version = "0.1.6"
version = "0.1.7"
edition = "2021"
publish = false

Expand Down
4 changes: 2 additions & 2 deletions sway-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sway-core"
version = "0.1.6"
version = "0.1.7"
authors = ["Fuel Labs <[email protected]>"]
edition = "2018"
homepage = "https://fuel.network/"
Expand All @@ -26,7 +26,7 @@ sha2 = "0.9"
smallvec = "1.7"
source-span = "2.4"
structopt = { version = "0.3", default-features = false, optional = true }
sway-types = { version = "0.1.6", path = "../sway-types" }
sway-types = { version = "0.1.7", path = "../sway-types" }
thiserror = "1.0"
uuid-b64 = "0.1"

Expand Down
10 changes: 5 additions & 5 deletions sway-core/src/semantic_analysis/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,11 @@ impl<'sc> Namespace<'sc> {
});
insert_type(TypeInfo::ErrorRecovery)
});
let methods = self.get_methods_for_type(r#type);
let methods = match methods[..] {
[] => namespace.get_methods_for_type(r#type),
_ => methods,
};
let local_methods = self.get_methods_for_type(r#type);
let mut ns_methods = namespace.get_methods_for_type(r#type);

let mut methods = local_methods;
methods.append(&mut ns_methods);

match methods
.into_iter()
Expand Down
4 changes: 2 additions & 2 deletions sway-fmt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sway-fmt"
version = "0.1.6"
version = "0.1.7"
authors = ["Fuel Labs <[email protected]>"]
edition = "2018"
homepage = "https://fuel.network/"
Expand All @@ -10,4 +10,4 @@ description = "Sway sway-fmt."

[dependencies]
ropey = "1.2"
sway-core = { version = "0.1.6", path = "../sway-core" }
sway-core = { version = "0.1.7", path = "../sway-core" }
8 changes: 4 additions & 4 deletions sway-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sway-server"
version = "0.1.6"
version = "0.1.7"
authors = ["Fuel Labs <[email protected]>"]
edition = "2018"
homepage = "https://fuel.network/"
Expand All @@ -14,7 +14,7 @@ lspower = "1.0.0"
pest = { version = "3.0", package = "fuel-pest" }
ropey = "1.2"
serde_json = "1.0.60"
sway-core = { version = "0.1.6", path = "../sway-core" }
sway-fmt = { version = "0.1.6", path = "../sway-fmt" }
sway-utils = { version = "0.1.6", path = "../sway-utils" }
sway-core = { version = "0.1.7", path = "../sway-core" }
sway-fmt = { version = "0.1.7", path = "../sway-fmt" }
sway-utils = { version = "0.1.7", path = "../sway-utils" }
tokio = { version = "1.3", features = ["io-std", "io-util", "macros", "net", "rt-multi-thread", "sync", "time"] }
2 changes: 1 addition & 1 deletion sway-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sway-types"
version = "0.1.6"
version = "0.1.7"
authors = ["Fuel Labs <[email protected]>"]
edition = "2018"
homepage = "https://fuel.network/"
Expand Down
2 changes: 1 addition & 1 deletion sway-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sway-utils"
version = "0.1.6"
version = "0.1.7"
authors = ["Fuel Labs <[email protected]>"]
edition = "2021"
homepage = "https://fuel.network/"
Expand Down
4 changes: 2 additions & 2 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "test"
version = "0.1.6"
version = "0.1.7"
authors = ["Fuel Labs <[email protected]>"]
edition = "2018"
publish = false

[dependencies]
forc = { version = "0.1.6", path = "../forc", features = ["test"], default-features = false }
forc = { version = "0.1.7", path = "../forc", features = ["test"], default-features = false }
fuel-asm = "0.1"
fuel-tx = "0.1"
fuel-vm = { version = "0.1", features = ["random"] }
Expand Down
3 changes: 2 additions & 1 deletion test/src/e2e_vm_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ pub fn run(filter_regex: Option<regex::Regex>) {
("block_height", ProgramState::Return(1)), // true
("b512_test", ProgramState::Return(1)), // true
("block_height", ProgramState::Return(1)), // true
("valid_impurity", ProgramState::Return(0)), // true
("valid_impurity", ProgramState::Return(0)), // false
("trait_override_bug", ProgramState::Return(7)),
];

project_names.into_iter().for_each(|(name, res)| {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "trait_override_bug"
author = "Fuel Labs <[email protected]>"
entry = "main.sw"
license = "Apache-2.0"

[dependencies]
std = { git = "http://github.com/FuelLabs/sway-lib-std" }
core = { git = "http://github.com/FuelLabs/sway-lib-core" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
36 changes: 36 additions & 0 deletions test/src/e2e_vm_tests/test_programs/trait_override_bug/src/main.sw
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
script;


// This bug was found by Nebula in discord. Adding this trait was causing other implementations on u64s to be overridden.

pub trait Shiftable {
fn lsh(self, other: Self) -> Self;
fn rsh(self, other: Self) -> Self;

}

impl Shiftable for u64 {
fn lsh(self, other: Self) -> Self {
asm(r1 : self, r2: other, r3) {
sll r3 r1 r2;
r3: u64
}
}

fn rsh(self, other: Self) -> Self {
asm(r1 : self, r2: other, r3) {
srl r3 r1 r2;
r3: u64
}
}
}

fn foo() -> u64 {
let mut x:u64 = 4;
x = 5 + 2;
x
}

fn main() -> u64 {
foo()
}

0 comments on commit 4038415

Please sign in to comment.