diff --git a/sway-core/src/asm_generation/fuel/data_section.rs b/sway-core/src/asm_generation/fuel/data_section.rs index ce8d5b0b081..198654c57bb 100644 --- a/sway-core/src/asm_generation/fuel/data_section.rs +++ b/sway-core/src/asm_generation/fuel/data_section.rs @@ -220,6 +220,7 @@ impl Entry { pub(crate) fn equiv(&self, entry: &Entry) -> bool { fn equiv_data(lhs: &Datum, rhs: &Datum) -> bool { match (lhs, rhs) { + (Datum::Byte(l), Datum::Byte(r)) => l == r, (Datum::Word(l), Datum::Word(r)) => l == r, (Datum::ByteArray(l), Datum::ByteArray(r)) => l == r, @@ -292,7 +293,7 @@ impl DataSection { .map(|entry| entry.has_copy_type()) } - /// Returns whether a specific [DataId] value has a byte entry. + /// Returns whether a specific [DataId] value is a byte entry. pub(crate) fn is_byte(&self, id: &DataId) -> Option { self.value_pairs .get(id.0 as usize) diff --git a/sway-core/src/ir_generation/convert.rs b/sway-core/src/ir_generation/convert.rs index 5ce522c7baf..bda60d85102 100644 --- a/sway-core/src/ir_generation/convert.rs +++ b/sway-core/src/ir_generation/convert.rs @@ -101,7 +101,7 @@ fn convert_resolved_type( } Ok(match ast_type { - // All integers are `u64`, see comment in convert_literal_to_value() above. + // See comment in convert_literal_to_value() above. TypeInfo::UnsignedInteger(IntegerBits::V256) => Type::get_uint256(context), TypeInfo::UnsignedInteger(IntegerBits::Eight) => Type::get_uint8(context), TypeInfo::UnsignedInteger(IntegerBits::Sixteen) diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index f1e29d8045e..57162b4e4e1 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -2685,7 +2685,10 @@ impl<'eng> FnCompiler<'eng> { ty_at_idx = field_type; break; } - offset += ir_type_size_in_bytes(context, &field_type); + offset += size_bytes_round_up_to_word_alignment!(ir_type_size_in_bytes( + context, + &field_type + )); } } Ok(offset / 8) diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs index 0e24410c336..42515bfd342 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs @@ -1701,6 +1701,7 @@ impl ty::TyExpression { }); }; + // start each element with the known array element type let initial_type = match ctx.engines().te().get(ctx.type_annotation()) { TypeInfo::Array(element_type, _) => ctx.engines().te().get(element_type.type_id), _ => TypeInfo::Unknown, @@ -1720,27 +1721,6 @@ impl ty::TyExpression { .collect(); let elem_type = typed_contents[0].return_type; - // for typed_elem in &typed_contents[1..] { - // let h = Handler::default(); - // ctx.by_ref() - // .with_type_annotation(elem_type) - // .unify_with_type_annotation(&h, typed_elem.return_type, &typed_elem.span); - - // let (new_errors, new_warnings) = h.consume(); - // let no_warnings = new_warnings.is_empty(); - // let no_errors = new_errors.is_empty(); - // for warn in new_warnings { - // handler.emit_warn(warn); - // } - // for err in new_errors { - // handler.emit_err(err); - // } - // // In both cases, if there are warnings or errors then break here, since we don't - // // need to spam type errors for every element once we have one. - // if !no_warnings && !no_errors { - // break; - // } - // } let array_count = typed_contents.len(); Ok(ty::TyExpression { @@ -2187,7 +2167,7 @@ mod tests { let handler = Handler::default(); let _comp_res = do_type_check_for_boolx2(&handler, expr); let (errors, _warnings) = handler.consume(); - dbg!(&errors); + assert!(errors.len() == 2); assert!(matches!(&errors[0], CompileError::TypeError(TypeError::MismatchedType { diff --git a/sway-lib-std/src/array_conversions/u16.sw b/sway-lib-std/src/array_conversions/u16.sw index d285975b2ea..4a29fb65cf6 100644 --- a/sway-lib-std/src/array_conversions/u16.sw +++ b/sway-lib-std/src/array_conversions/u16.sw @@ -25,11 +25,11 @@ impl u16 { asm(input: self, off: 0xFF, i: 0x8, output: output, r1) { and r1 input off; - sw output r1 i0; + sb output r1 i0; srl r1 input i; and r1 r1 off; - sw output r1 i1; + sb output r1 i1; output: [u8; 2] } @@ -85,10 +85,10 @@ impl u16 { asm(input: self, off: 0xFF, i: 0x8, output: output, r1) { srl r1 input i; - sw output r1 i0; + sb output r1 i0; and r1 input off; - sw output r1 i1; + sb output r1 i1; output: [u8; 2] } @@ -102,7 +102,7 @@ impl u16 { /// /// # Returns /// - /// * [u32] - The resulting `u16` value. + /// * [u16] - The resulting `u16` value. /// /// # Examples /// diff --git a/sway-lib-std/src/array_conversions/u32.sw b/sway-lib-std/src/array_conversions/u32.sw index aeab723beaa..1ad40085548 100644 --- a/sway-lib-std/src/array_conversions/u32.sw +++ b/sway-lib-std/src/array_conversions/u32.sw @@ -27,19 +27,19 @@ impl u32 { asm(input: self, off: 0xFF, i: 0x8, j: 0x10, k: 0x18, output: output, r1) { and r1 input off; - sw output r1 i0; + sb output r1 i0; srl r1 input i; and r1 r1 off; - sw output r1 i1; + sb output r1 i1; srl r1 input j; and r1 r1 off; - sw output r1 i2; + sb output r1 i2; srl r1 input k; and r1 r1 off; - sw output r1 i3; + sb output r1 i3; output: [u8; 4] } @@ -102,18 +102,18 @@ impl u32 { asm(input: self, off: 0xFF, i: 0x8, j: 0x10, k: 0x18, output: output, r1) { srl r1 input k; and r1 r1 off; - sw output r1 i0; + sb output r1 i0; srl r1 input j; and r1 r1 off; - sw output r1 i1; + sb output r1 i1; srl r1 input i; and r1 r1 off; - sw output r1 i2; + sb output r1 i2; and r1 input off; - sw output r1 i3; + sb output r1 i3; output: [u8; 4] } diff --git a/sway-lib-std/src/array_conversions/u64.sw b/sway-lib-std/src/array_conversions/u64.sw index 597254a6834..7e55fac658a 100644 --- a/sway-lib-std/src/array_conversions/u64.sw +++ b/sway-lib-std/src/array_conversions/u64.sw @@ -31,35 +31,35 @@ impl u64 { asm(input: self, off: 0xFF, i: 0x8, j: 0x10, k: 0x18, l: 0x20, m: 0x28, n: 0x30, o: 0x38, output: output, r1) { and r1 input off; - sw output r1 i0; + sb output r1 i0; srl r1 input i; and r1 r1 off; - sw output r1 i1; + sb output r1 i1; srl r1 input j; and r1 r1 off; - sw output r1 i2; + sb output r1 i2; srl r1 input k; and r1 r1 off; - sw output r1 i3; + sb output r1 i3; srl r1 input l; and r1 r1 off; - sw output r1 i4; + sb output r1 i4; srl r1 input m; and r1 r1 off; - sw output r1 i5; + sb output r1 i5; srl r1 input n; and r1 r1 off; - sw output r1 i6; + sb output r1 i6; srl r1 input o; and r1 r1 off; - sw output r1 i7; + sb output r1 i7; output: [u8; 8] } @@ -143,35 +143,35 @@ impl u64 { asm(input: self, off: 0xFF, i: 0x8, j: 0x10, k: 0x18, l: 0x20, m: 0x28, n: 0x30, o: 0x38, output: output, r1) { and r1 input off; - sw output r1 i7; + sb output r1 i7; srl r1 input i; and r1 r1 off; - sw output r1 i6; + sb output r1 i6; srl r1 input j; and r1 r1 off; - sw output r1 i5; + sb output r1 i5; srl r1 input k; and r1 r1 off; - sw output r1 i4; + sb output r1 i4; srl r1 input l; and r1 r1 off; - sw output r1 i3; + sb output r1 i3; srl r1 input m; and r1 r1 off; - sw output r1 i2; + sb output r1 i2; srl r1 input n; and r1 r1 off; - sw output r1 i1; + sb output r1 i1; srl r1 input o; and r1 r1 off; - sw output r1 i0; + sb output r1 i0; output: [u8; 8] } diff --git a/test/src/sdk-harness/Cargo.lock b/test/src/sdk-harness/Cargo.lock index e0d18de920e..c27437f0b52 100644 --- a/test/src/sdk-harness/Cargo.lock +++ b/test/src/sdk-harness/Cargo.lock @@ -1545,7 +1545,6 @@ dependencies = [ [[package]] name = "fuels" version = "0.48.0" -source = "git+https://github.com/FuelLabs/fuels-rs.git?branch=IGI-111/int-mem-repr#e06ad8f0a6694a1f6c98fc042364b3042d4b2da5" dependencies = [ "fuel-core", "fuel-core-client", @@ -1560,7 +1559,6 @@ dependencies = [ [[package]] name = "fuels-accounts" version = "0.48.0" -source = "git+https://github.com/FuelLabs/fuels-rs.git?branch=IGI-111/int-mem-repr#e06ad8f0a6694a1f6c98fc042364b3042d4b2da5" dependencies = [ "async-trait", "chrono", @@ -1582,7 +1580,6 @@ dependencies = [ [[package]] name = "fuels-code-gen" version = "0.48.0" -source = "git+https://github.com/FuelLabs/fuels-rs.git?branch=IGI-111/int-mem-repr#e06ad8f0a6694a1f6c98fc042364b3042d4b2da5" dependencies = [ "Inflector", "fuel-abi-types", @@ -1597,7 +1594,6 @@ dependencies = [ [[package]] name = "fuels-core" version = "0.48.0" -source = "git+https://github.com/FuelLabs/fuels-rs.git?branch=IGI-111/int-mem-repr#e06ad8f0a6694a1f6c98fc042364b3042d4b2da5" dependencies = [ "bech32", "chrono", @@ -1622,7 +1618,6 @@ dependencies = [ [[package]] name = "fuels-macros" version = "0.48.0" -source = "git+https://github.com/FuelLabs/fuels-rs.git?branch=IGI-111/int-mem-repr#e06ad8f0a6694a1f6c98fc042364b3042d4b2da5" dependencies = [ "fuels-code-gen", "itertools 0.11.0", @@ -1635,7 +1630,6 @@ dependencies = [ [[package]] name = "fuels-programs" version = "0.48.0" -source = "git+https://github.com/FuelLabs/fuels-rs.git?branch=IGI-111/int-mem-repr#e06ad8f0a6694a1f6c98fc042364b3042d4b2da5" dependencies = [ "async-trait", "bytes", @@ -1654,7 +1648,6 @@ dependencies = [ [[package]] name = "fuels-test-helpers" version = "0.48.0" -source = "git+https://github.com/FuelLabs/fuels-rs.git?branch=IGI-111/int-mem-repr#e06ad8f0a6694a1f6c98fc042364b3042d4b2da5" dependencies = [ "fuel-core", "fuel-core-chain-config", diff --git a/test/src/sdk-harness/test_projects/hashing/src/main.sw b/test/src/sdk-harness/test_projects/hashing/src/main.sw index 019f56bb30f..79d28e3d7fc 100644 --- a/test/src/sdk-harness/test_projects/hashing/src/main.sw +++ b/test/src/sdk-harness/test_projects/hashing/src/main.sw @@ -149,7 +149,6 @@ impl MyContract for Contract { } fn keccak256_u8(value: u8) -> b256 { - log(value); keccak256(value) } @@ -178,8 +177,6 @@ impl MyContract for Contract { } fn keccak256_tuple(value: (bool, u64)) -> b256 { - log(value.0); - log(value.1); keccak256(value) } diff --git a/test/src/sdk-harness/test_projects/messages/src/main.sw b/test/src/sdk-harness/test_projects/messages/src/main.sw index 6217ad4451d..f59db88b12a 100644 --- a/test/src/sdk-harness/test_projects/messages/src/main.sw +++ b/test/src/sdk-harness/test_projects/messages/src/main.sw @@ -54,9 +54,6 @@ impl TestFuelCoin for Contract { send_typed_message(recipient, msg_data, coins); } fn send_typed_message_string(recipient: b256, msg_data: str[4], coins: u64) { - log(recipient); - log(msg_data); - log(coins); send_typed_message(recipient, msg_data, coins); } } diff --git a/test/src/sdk-harness/test_projects/parsing_logs/mod.rs b/test/src/sdk-harness/test_projects/parsing_logs/mod.rs index a30713a3102..927a7ec05d5 100644 --- a/test/src/sdk-harness/test_projects/parsing_logs/mod.rs +++ b/test/src/sdk-harness/test_projects/parsing_logs/mod.rs @@ -106,13 +106,13 @@ async fn test_parse_logs_generic_types() -> Result<()> { let contract_methods = instance.methods(); let response = contract_methods.produce_logs_generic_types().call().await?; - // let log_struct = response.decode_logs_with_type::>()?; + let log_struct = response.decode_logs_with_type::>()?; let log_enum = response.decode_logs_with_type::>()?; - // let log_struct_nested = - // response.decode_logs_with_type::>>()?; - // let log_struct_deeply_nested = response.decode_logs_with_type::>, - // >>()?; + let log_struct_nested = + response.decode_logs_with_type::>>()?; + let log_struct_deeply_nested = response.decode_logs_with_type::>, + >>()?; let l = [1u8, 2u8, 3u8]; let expected_struct = StructWithGeneric { @@ -120,22 +120,22 @@ async fn test_parse_logs_generic_types() -> Result<()> { field_2: 64, }; let expected_enum = EnumWithGeneric::VariantOne(l); - // let expected_nested_struct = StructWithNestedGeneric { - // field_1: expected_struct.clone(), - // field_2: 64, - // }; - // let expected_deeply_nested_struct = StructDeeplyNestedGeneric { - // field_1: expected_nested_struct.clone(), - // field_2: 64, - // }; - - // assert_eq!(log_struct, vec![expected_struct]); + let expected_nested_struct = StructWithNestedGeneric { + field_1: expected_struct.clone(), + field_2: 64, + }; + let expected_deeply_nested_struct = StructDeeplyNestedGeneric { + field_1: expected_nested_struct.clone(), + field_2: 64, + }; + + assert_eq!(log_struct, vec![expected_struct]); assert_eq!(log_enum, vec![expected_enum]); - // assert_eq!(log_struct_nested, vec![expected_nested_struct]); - // assert_eq!( - // log_struct_deeply_nested, - // vec![expected_deeply_nested_struct] - // ); + assert_eq!(log_struct_nested, vec![expected_nested_struct]); + assert_eq!( + log_struct_deeply_nested, + vec![expected_deeply_nested_struct] + ); Ok(()) } diff --git a/test/src/sdk-harness/test_projects/result_in_abi/mod.rs b/test/src/sdk-harness/test_projects/result_in_abi/mod.rs index 129e4b0ce81..44c98ac3a9a 100644 --- a/test/src/sdk-harness/test_projects/result_in_abi/mod.rs +++ b/test/src/sdk-harness/test_projects/result_in_abi/mod.rs @@ -213,22 +213,22 @@ async fn test_array() -> Result<()> { let (instance, _id) = get_result_in_abi_instance().await; let contract_methods = instance.methods(); - // let input = Ok([ - // Ok( - // Address::from_str("0x4242424242424242424242424242424242424242424242424242424242424242") - // .unwrap(), - // ), - // Ok( - // Address::from_str("0x6969696969696969696969696969696969696969696969696969696969696969") - // .unwrap(), - // ), - // Ok( - // Address::from_str("0x9999999999999999999999999999999999999999999999999999999999999999") - // .unwrap(), - // ), - // ]); - // let response = contract_methods.array_test(input.clone()).call().await?; - // assert_eq!(input, response.value); + let input = Ok([ + Ok( + Address::from_str("0x4242424242424242424242424242424242424242424242424242424242424242") + .unwrap(), + ), + Ok( + Address::from_str("0x6969696969696969696969696969696969696969696969696969696969696969") + .unwrap(), + ), + Ok( + Address::from_str("0x9999999999999999999999999999999999999999999999999999999999999999") + .unwrap(), + ), + ]); + let response = contract_methods.array_test(input.clone()).call().await?; + assert_eq!(input, response.value); let input = Ok([ Err(SomeError::SomeErrorString("error".try_into().unwrap())), @@ -241,17 +241,17 @@ async fn test_array() -> Result<()> { let response = contract_methods.array_test(input.clone()).call().await?; assert_eq!(input, response.value); - // let input = Ok([ - // Err(SomeError::SomeErrorString("error".try_into().unwrap())), - // Err(SomeError::SomeErrorString("error".try_into().unwrap())), - // Err(SomeError::SomeErrorString("error".try_into().unwrap())), - // ]); - // let response = contract_methods.array_test(input.clone()).call().await?; - // assert_eq!(input, response.value); + let input = Ok([ + Err(SomeError::SomeErrorString("error".try_into().unwrap())), + Err(SomeError::SomeErrorString("error".try_into().unwrap())), + Err(SomeError::SomeErrorString("error".try_into().unwrap())), + ]); + let response = contract_methods.array_test(input.clone()).call().await?; + assert_eq!(input, response.value); - // let input = Err(SomeError::SomeErrorString("error".try_into().unwrap())); - // let response = contract_methods.array_test(input.clone()).call().await?; - // assert_eq!(input, response.value); + let input = Err(SomeError::SomeErrorString("error".try_into().unwrap())); + let response = contract_methods.array_test(input.clone()).call().await?; + assert_eq!(input, response.value); Ok(()) } diff --git a/test/src/sdk-harness/test_projects/storage_init/mod.rs b/test/src/sdk-harness/test_projects/storage_init/mod.rs index d390ef960a4..331f92a230e 100644 --- a/test/src/sdk-harness/test_projects/storage_init/mod.rs +++ b/test/src/sdk-harness/test_projects/storage_init/mod.rs @@ -29,12 +29,13 @@ async fn test_storage_init_instance() -> TestStorageInitContract #[tokio::test] async fn test_initializers() { let methods = test_storage_init_instance().await.methods(); - let l = methods.test_initializers().call().await; - let receipts = match l { - Ok(l) => l.receipts, - Err(Error::RevertTransactionError { receipts, .. }) => receipts, - _ => todo!(), - }; - pretty_assertions::assert_eq!(&receipts[4].data(), &receipts[5].data()); - // assert!(l.value); + assert!(methods.test_initializers().call().await.unwrap().value); + // let l = methods.test_initializers().call().await; + // let (receipts, value) = match l { + // Ok(l) => (l.receipts, l.value), + // Err(Error::RevertTransactionError { receipts, .. }) => receipts, + // _ => todo!(), + // }; + // pretty_assertions::assert_eq!(&receipts[4].data(), &receipts[5].data()); + // assert!(value); } diff --git a/test/src/sdk-harness/test_projects/storage_init/src/main.sw b/test/src/sdk-harness/test_projects/storage_init/src/main.sw index b857efd30e3..196bf7aebe4 100644 --- a/test/src/sdk-harness/test_projects/storage_init/src/main.sw +++ b/test/src/sdk-harness/test_projects/storage_init/src/main.sw @@ -120,49 +120,29 @@ impl ExperimentalStorageInitTest for Contract { let e2: E = E::A(777); let string: str[40] = __to_str_array("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - - log(1); assert(storage.x.read() == x); - log(1); assert(storage.y.read() == y); - log(1); - log(storage.s.read()); - log(s); assert(storage.s.read() == s); - log(1); assert(storage.boolean.read() == boolean); - log(1); assert(storage.int8.read() == int8); - log(1); + assert(storage.int16.read() == int16); - log(1); assert(storage.int32.read() == int32); - log(1); assert(storage.s.x.read() == s.x); - log(1); assert(storage.s.y.read() == s.y); - log(1); assert(storage.s.z.read() == s.z); - log(1); assert(storage.s.t.read() == s.t); - log(1); assert(storage.s.t.x.read() == s.t.x); - log(1); assert(storage.s.t.y.read() == s.t.y); - log(1); assert(storage.s.t.z.read() == s.t.z); - log(1); assert(storage.s.t.boolean.read() == s.t.boolean); - log(1); assert(storage.s.t.int8.read() == s.t.int8); - log(1); assert(storage.s.t.int16.read() == s.t.int16); - log(1); assert(storage.s.t.int32.read() == s.t.int32); - log(1); + assert(storage.e.read() == e); - log(1); assert(storage.e2.read() == e2); + assert(sha256_str_array(storage.string.read()) == sha256_str_array(string)); true } diff --git a/test/src/sdk-harness/test_projects/storage_map/src/main.sw b/test/src/sdk-harness/test_projects/storage_map/src/main.sw index 1678663ff81..f554cad3a4c 100644 --- a/test/src/sdk-harness/test_projects/storage_map/src/main.sw +++ b/test/src/sdk-harness/test_projects/storage_map/src/main.sw @@ -372,16 +372,12 @@ impl StorageMapTest for Contract { #[storage(read, write)] fn insert_into_bool_to_u64_map(key: bool, value: u64) { - log(key); - log(value); storage.map11.insert(key, value); } #[storage(read)] fn get_from_bool_to_u64_map(key: bool) -> Option { - let r = storage.map11.get(key).try_read(); - log(r); - r + storage.map11.get(key).try_read() } #[storage(write)] diff --git a/test/src/sdk-harness/test_projects/storage_vec/testgen.rs b/test/src/sdk-harness/test_projects/storage_vec/testgen.rs index fd858e9c880..b092c30c828 100644 --- a/test/src/sdk-harness/test_projects/storage_vec/testgen.rs +++ b/test/src/sdk-harness/test_projects/storage_vec/testgen.rs @@ -526,38 +526,24 @@ macro_rules! testgen { async fn can_fill() { let instance = get_contract_instance().await; - dbg!(&$arg0); push(&instance, $arg0).await; - dbg!(&$arg1); push(&instance, $arg1).await; - dbg!(&$arg2); push(&instance, $arg2).await; - dbg!(&$arg3); push(&instance, $arg3).await; - dbg!(7); assert_eq!(len(&instance).await, 4); - dbg!(8); assert_eq!(get(&instance, 0).await, $arg0); - dbg!(9); assert_eq!(get(&instance, 1).await, $arg1); assert_eq!(get(&instance, 2).await, $arg2); assert_eq!(get(&instance, 3).await, $arg3); - dbg!(&$arg4); fill(&instance, $arg4).await; - dbg!(1); assert_eq!(len(&instance).await, 4); - dbg!(2); assert_eq!(get(&instance, 0).await, $arg4); - dbg!(3); assert_eq!(get(&instance, 1).await, $arg4); - dbg!(4); assert_eq!(get(&instance, 2).await, $arg4); - dbg!(5); assert_eq!(get(&instance, 3).await, $arg4); - dbg!(6); } #[tokio::test]