diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/.gitignore b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/.gitignore deleted file mode 100644 index 77d3844f58c..00000000000 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -out -target diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/Forc.lock b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/Forc.lock index 8407bd5c37c..fe603fe62ef 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/Forc.lock +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/Forc.lock @@ -5,9 +5,4 @@ source = "path+from-root-D73E65B1F4E48513" [[package]] name = "function_return_type_unification" source = "member" -dependencies = ["std"] - -[[package]] -name = "std" -source = "path+from-root-D73E65B1F4E48513" dependencies = ["core"] diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/Forc.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/Forc.toml index 96f4447a531..ebe0edcfda3 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/Forc.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/Forc.toml @@ -5,4 +5,4 @@ entry = "main.sw" license = "Apache-2.0" [dependencies] -std = { path = "../../../../reduced_std_libs/sway-lib-std-assert" } +core = { path = "../../../../../../../sway-lib-core" } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/src/main.sw index 9d5c8d4d08c..761b788e150 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/src/main.sw @@ -22,8 +22,7 @@ where T: Build, T::build() } -fn main() -> bool { - let _:u32 = produce(); - - true +fn main() -> u32 { + let x: u32 = produce(); + x } \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/test.toml index 1591686ff87..bdd8e5d330a 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/function_return_type_unification/test.toml @@ -1,4 +1,4 @@ category = "run" -expected_result = { action = "return", value = 1 } -expected_result_new_encoding = { action = "return_data", value = "01" } +expected_result = { action = "return", value = 31 } +expected_result_new_encoding = { action = "return_data", value = "0000001f" } validate_abi = false diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/Forc.lock b/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/Forc.lock new file mode 100644 index 00000000000..c6f5f7c1b5c --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/Forc.lock @@ -0,0 +1,8 @@ +[[package]] +name = "core" +source = "path+from-root-9D1294DAC07670CA" + +[[package]] +name = "type_inference_propagation_of_type_constraints" +source = "member" +dependencies = ["core"] diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/Forc.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/Forc.toml new file mode 100644 index 00000000000..c3320e028d2 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/Forc.toml @@ -0,0 +1,8 @@ +[project] +name = "type_inference_propagation_of_type_constraints" +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" + +[dependencies] +core = { path = "../../../../../../../sway-lib-core" } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/src/main.sw new file mode 100644 index 00000000000..4d2413c6d49 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/src/main.sw @@ -0,0 +1,64 @@ +// This tests proves that https://github.com/FuelLabs/sway/issues/6379 is fixed. + +script; + +trait Build { + fn build() -> Self; +} + +fn produce() -> T where T: Build { + T::build() +} + +impl Build for u8 { + fn build() -> Self { + 7 + } +} + +impl Build for u32 { + fn build() -> Self { + 31 + } +} + +impl Build for u64 { + fn build() -> Self { + 63 + } +} + +fn consume_u8(a: u8) -> u8 { + a +} + +fn consume_u32(a: u32) -> u32 { + a +} + +fn consume_u64(a: u64) -> u64 { + a +} + +fn main() -> (u8, u32, u64) { + let a = produce_consume_u8(); + let b = produce_consume_u32(); + let c = produce_consume_u64(); + + (a, b, c) +} + +fn produce_consume_u8() -> u8 { + let x = produce(); + consume_u8(x) +} + +fn produce_consume_u32() -> u32 { + let x = produce(); + consume_u32(x) +} + +fn produce_consume_u64() -> u64 { + let x = produce(); + consume_u64(x) +} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/test.toml new file mode 100644 index 00000000000..17578590d9b --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/type_inference_propagation_of_type_constraints/test.toml @@ -0,0 +1,4 @@ +category = "run" +expected_result = { action = "return_data", value = "0700000000000000 000000000000001f 000000000000003f" } +expected_result_new_encoding = { action = "return_data", value = "07 0000001f 000000000000003f" } +validate_abi = false