Skip to content

Commit

Permalink
Merge branch 'master' into esdrubal/6395
Browse files Browse the repository at this point in the history
  • Loading branch information
IGI-111 authored Nov 28, 2024
2 parents f4d9fba + a02e8ea commit 0806797
Show file tree
Hide file tree
Showing 18 changed files with 435 additions and 151 deletions.
8 changes: 4 additions & 4 deletions forc-plugins/forc-client/tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ async fn test_simple_deploy() {
node.kill().unwrap();
let expected = vec![DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"5c51b8904c539700852c646c6700fddab4b80477f66e56fb2515736facd84e69",
"02a7e78ef0514b80ab56b409f06f895d8939640b6f6d746fcbb15d3e0c6a1a3b",
)
.unwrap(),
proxy: None,
Expand Down Expand Up @@ -416,7 +416,7 @@ async fn test_deploy_submit_only() {
node.kill().unwrap();
let expected = vec![DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"5c51b8904c539700852c646c6700fddab4b80477f66e56fb2515736facd84e69",
"02a7e78ef0514b80ab56b409f06f895d8939640b6f6d746fcbb15d3e0c6a1a3b",
)
.unwrap(),
proxy: None,
Expand Down Expand Up @@ -462,12 +462,12 @@ async fn test_deploy_fresh_proxy() {
node.kill().unwrap();
let impl_contract = DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"5c51b8904c539700852c646c6700fddab4b80477f66e56fb2515736facd84e69",
"02a7e78ef0514b80ab56b409f06f895d8939640b6f6d746fcbb15d3e0c6a1a3b",
)
.unwrap(),
proxy: Some(
ContractId::from_str(
"7a78517c2c3322028db65e54893dc97958fa3d7c846a66f5675859e64f927540",
"6eb0db0e120222a4ac3ced8dfbf15ae56753b852aa7989849fa20e5aca47af44",
)
.unwrap(),
),
Expand Down
286 changes: 169 additions & 117 deletions sway-core/src/asm_generation/fuel/optimizations.rs

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions sway-core/src/transform/to_parsed_lang/convert_parse_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ pub(crate) fn type_name_to_type_info_opt(name: &Ident) -> Option<TypeInfo> {
"str" => Some(TypeInfo::StringSlice),
"raw_ptr" => Some(TypeInfo::RawUntypedPtr),
"raw_slice" => Some(TypeInfo::RawUntypedSlice),
"Self" | "self" => Some(TypeInfo::new_self_type(name.span())),
"Self" => Some(TypeInfo::new_self_type(name.span())),
"Contract" => Some(TypeInfo::Contract),
_other => None,
}
Expand Down Expand Up @@ -4600,7 +4600,10 @@ fn path_type_to_type_info(
}
}
None => {
if name.as_str() == "ContractCaller" {
if name.as_str() == "self" {
let error = ConvertParseTreeError::UnknownTypeNameSelf { span };
return Err(handler.emit_err(error.into()));
} else if name.as_str() == "ContractCaller" {
if root_opt.is_some() || !suffix.is_empty() {
let error = ConvertParseTreeError::FullySpecifiedTypesNotSupported { span };
return Err(handler.emit_err(error.into()));
Expand Down
3 changes: 3 additions & 0 deletions sway-error/src/convert_parse_tree_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ pub enum ConvertParseTreeError {
UnexpectedValueForCfgExperimental { span: Span },
#[error("Unexpected attribute value: \"{value}\" for attribute: \"cfg\"")]
InvalidCfgArg { span: Span, value: String },
#[error("Unknown type name \"self\". A self type with a similar name exists (notice the capitalization): `Self`")]
UnknownTypeNameSelf { span: Span },
}

impl Spanned for ConvertParseTreeError {
Expand Down Expand Up @@ -185,6 +187,7 @@ impl Spanned for ConvertParseTreeError {
ConvertParseTreeError::ExpectedCfgProgramTypeArgValue { span } => span.clone(),
ConvertParseTreeError::UnexpectedValueForCfgExperimental { span } => span.clone(),
ConvertParseTreeError::InvalidCfgArg { span, .. } => span.clone(),
ConvertParseTreeError::UnknownTypeNameSelf { span } => span.clone(),
}
}
}
2 changes: 1 addition & 1 deletion sway-lib-std/src/bytes.sw
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ impl Bytes {
/// assert(bytes.capacity() == first_cap + second_cap);
/// }
/// ```
pub fn append(ref mut self, ref mut other: self) {
pub fn append(ref mut self, ref mut other: Self) {
let other_len = other.len();
if other_len == 0 {
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[[package]]
name = "core"
source = "path+from-root-722DFCAB6A209427"

[[package]]
name = "self_return_type"
source = "member"
dependencies = ["core"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "self_return_type"
authors = ["Fuel Labs <[email protected]>"]
entry = "main.sw"
license = "Apache-2.0"
implicit-std = false

[dependencies]
core = { path = "../../../../../../sway-lib-core" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
script;
trait MyTrait {
fn foo(self, other: Self) -> Self;
}
impl MyTrait for u8 {
fn foo(self, other: Self) -> self {
self
}
}
fn main() -> () {
let a = 1u8;
let _ = a.foo(2u8);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
category = "fail"

# check: $()fn foo(self, other: Self) -> self {
# nextln: $()Unknown type name "self". A self type with a similar name exists (notice the capitalization): `Self`
Original file line number Diff line number Diff line change
Expand Up @@ -62,82 +62,82 @@
{
"concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903",
"name": "BOOL",
"offset": 7120
"offset": 7048
},
{
"concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b",
"name": "U8",
"offset": 7312
"offset": 7240
},
{
"concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b",
"name": "ANOTHER_U8",
"offset": 7048
"offset": 6976
},
{
"concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef",
"name": "U16",
"offset": 7256
"offset": 7184
},
{
"concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc",
"name": "U32",
"offset": 7296
"offset": 7224
},
{
"concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc",
"name": "U64",
"offset": 7304
"offset": 7232
},
{
"concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e",
"name": "U256",
"offset": 7264
"offset": 7192
},
{
"concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b",
"name": "B256",
"offset": 7088
"offset": 7016
},
{
"concreteTypeId": "81fc10c4681a3271cf2d66b2ec6fbc8ed007a442652930844fcf11818c295bff",
"name": "CONFIGURABLE_STRUCT",
"offset": 7208
"offset": 7136
},
{
"concreteTypeId": "a2922861f03be8a650595dd76455b95383a61b46dd418f02607fa2e00dc39d5c",
"name": "CONFIGURABLE_ENUM_A",
"offset": 7128
"offset": 7056
},
{
"concreteTypeId": "a2922861f03be8a650595dd76455b95383a61b46dd418f02607fa2e00dc39d5c",
"name": "CONFIGURABLE_ENUM_B",
"offset": 7168
"offset": 7096
},
{
"concreteTypeId": "4926d35d1a5157936b0a29bc126b8aace6d911209a5c130e9b716b0c73643ea6",
"name": "ARRAY_BOOL",
"offset": 7056
"offset": 6984
},
{
"concreteTypeId": "776fb5a3824169d6736138565fdc20aad684d9111266a5ff6d5c675280b7e199",
"name": "ARRAY_U64",
"offset": 7064
"offset": 6992
},
{
"concreteTypeId": "c998ca9a5f221fe7b5c66ae70c8a9562b86d964408b00d17f883c906bc1fe4be",
"name": "TUPLE_BOOL_U64",
"offset": 7240
"offset": 7168
},
{
"concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a",
"name": "STR_4",
"offset": 7232
"offset": 7160
},
{
"concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b",
"name": "NOT_USED",
"offset": 7224
"offset": 7152
}
],
"encodingVersion": "1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cmds = ["forc build --path {root} --release --ir final"]
cmds = ["forc build --path {root} --release --ir final --asm final"]
Loading

0 comments on commit 0806797

Please sign in to comment.