text stringlengths 19 585k | label stringclasses 2
values | category stringclasses 2
values | language stringclasses 14
values | repo stringclasses 932
values | sha stringlengths 40 40 |
|---|---|---|---|---|---|
@@ -92,21 +92,89 @@ impl AbstractInstructionSet {
self
}
- pub(crate) fn remove_redundant_ops(mut self) -> AbstractInstructionSet {
- self.ops.retain(|op| {
- // It is easier to think in terms of operations we want to remove
- // than the operations we want to retain ;-)
... | bad | review | rust | FuelLabs/sway | 7575fe5b2b56f1d8bdc4c5283324d25c90f495da |
diff --git a/sway-core/src/asm_generation/fuel/optimizations/misc.rs b/sway-core/src/asm_generation/fuel/optimizations/misc.rs
index 9e59fa39a7c..f3229407cbf 100644
--- a/sway-core/src/asm_generation/fuel/optimizations/misc.rs
+++ b/sway-core/src/asm_generation/fuel/optimizations/misc.rs
@@ -81,7 +81,7 @@ impl Abstract... | good | review_fixed | rust | FuelLabs/sway | 7575fe5b2b56f1d8bdc4c5283324d25c90f495da |
@@ -92,21 +92,89 @@ impl AbstractInstructionSet {
self
}
- pub(crate) fn remove_redundant_ops(mut self) -> AbstractInstructionSet {
- self.ops.retain(|op| {
- // It is easier to think in terms of operations we want to remove
- // than the operations we want to retain ;-)
... | bad | review | rust | FuelLabs/sway | 7575fe5b2b56f1d8bdc4c5283324d25c90f495da |
diff --git a/sway-core/src/asm_generation/fuel/optimizations/misc.rs b/sway-core/src/asm_generation/fuel/optimizations/misc.rs
index 9e59fa39a7c..f3229407cbf 100644
--- a/sway-core/src/asm_generation/fuel/optimizations/misc.rs
+++ b/sway-core/src/asm_generation/fuel/optimizations/misc.rs
@@ -81,7 +81,7 @@ impl Abstract... | good | review_fixed | rust | FuelLabs/sway | 7575fe5b2b56f1d8bdc4c5283324d25c90f495da |
@@ -0,0 +1,20 @@
+// target-fuelvm
+script;
+
+fn main() -> u64 {
+ let src: u64 = 42;
+ let mut dst: u64 = 0;
+ asm(dst_ptr: dst, src_ptr: src, zero: 0u64) { | bad | review | FuelLabs/sway | 8d92e1af0a83adeb50949f28568b38ed824b8b05 | |
diff --git a/test/src/ir_generation/tests/mcp_zero_len.sw b/test/src/ir_generation/tests/mcp_zero_len.sw
new file mode 100644
index 00000000000..288fe3e9a37
--- /dev/null
+++ b/test/src/ir_generation/tests/mcp_zero_len.sw
@@ -0,0 +1,26 @@
+// target-fuelvm
+script;
+
+fn main() -> u64 {
+ let src: u64 = 42;
+ let... | good | review_fixed | FuelLabs/sway | 8d92e1af0a83adeb50949f28568b38ed824b8b05 | |
@@ -0,0 +1,20 @@
+// target-fuelvm
+script;
+
+fn main() -> u64 {
+ let src: u64 = 42;
+ let mut dst: u64 = 0;
+ asm(dst_ptr: dst, src_ptr: src, zero: 0u64) {
+ mcp dst_ptr src_ptr zero; | bad | review | FuelLabs/sway | 8d92e1af0a83adeb50949f28568b38ed824b8b05 | |
diff --git a/test/src/ir_generation/tests/mcp_zero_len.sw b/test/src/ir_generation/tests/mcp_zero_len.sw
new file mode 100644
index 00000000000..288fe3e9a37
--- /dev/null
+++ b/test/src/ir_generation/tests/mcp_zero_len.sw
@@ -0,0 +1,26 @@
+// target-fuelvm
+script;
+
+fn main() -> u64 {
+ let src: u64 = 42;
+ let... | good | review_fixed | FuelLabs/sway | 8d92e1af0a83adeb50949f28568b38ed824b8b05 | |
@@ -150,21 +144,36 @@ impl Cid {
Ok(())
}
- /// Using local node, fetches the content described by this cid.
- pub(crate) async fn fetch_with_client(
- &self,
- ipfs_client: &IpfsClient,
- dst: &Path,
- ) -> Result<()> {
+
+ /// Using a local IPFS node, fetches the conte... | bad | review | rust | FuelLabs/sway | 457ce1d19657e7504060ea9ee985a80fc2b4201e |
diff --git a/forc-pkg/src/source/ipfs.rs b/forc-pkg/src/source/ipfs.rs
index 7ac1cf08a7e..4a5a027e3bb 100644
--- a/forc-pkg/src/source/ipfs.rs
+++ b/forc-pkg/src/source/ipfs.rs
@@ -3,12 +3,9 @@ use crate::{
manifest::{self, PackageManifestFile},
source,
};
-use anyhow::Result;
+use anyhow::{Context, Result};... | good | review_fixed | rust | FuelLabs/sway | 457ce1d19657e7504060ea9ee985a80fc2b4201e |
@@ -350,6 +390,76 @@ mod tests {
assert_eq!(&serialized, string);
}
+ #[test]
+ fn test_parse_ipfs_api_multiaddr() {
+ assert_eq!(
+ parse_ipfs_api_multiaddr("/ip4/127.0.0.1/tcp/5001").as_deref(),
+ Some("http://127.0.0.1:5001")
+ );
+ assert_eq!(
+ ... | bad | review | rust | FuelLabs/sway | 457ce1d19657e7504060ea9ee985a80fc2b4201e |
diff --git a/forc-pkg/src/source/ipfs.rs b/forc-pkg/src/source/ipfs.rs
index 7ac1cf08a7e..4a5a027e3bb 100644
--- a/forc-pkg/src/source/ipfs.rs
+++ b/forc-pkg/src/source/ipfs.rs
@@ -3,12 +3,9 @@ use crate::{
manifest::{self, PackageManifestFile},
source,
};
-use anyhow::Result;
+use anyhow::{Context, Result};... | good | review_fixed | rust | FuelLabs/sway | 457ce1d19657e7504060ea9ee985a80fc2b4201e |
@@ -1180,6 +1188,10 @@ pub fn compile_to_asm(
experimental,
)?;
+ if let Ok(t) = ast_res.typed.as_ref() {
+ dbg!(&t.decls_to_check);
+ } | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs
index 9a1c701bccc..9cffb101efb 100644
--- a/sway-core/src/lib.rs
+++ b/sway-core/src/lib.rs
@@ -26,11 +26,18 @@ pub mod source_map;
pub mod transform;
pub mod type_system;
+use crate::decl_engine::DeclEngineGet as _;
+use crate::engine_threading::SpannedWithE... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -0,0 +1,25 @@
+script;
+
+mod another_file;
+use another_file::InnerStruct;
+
+#[require(trivially_decodable = "true")]
+struct MyStruct {
+ a: bool,
+ b: InnerStruct,
+ c: SomeEnum,
+ d: Vec<u64>,
+} | bad | review | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/src/main.sw
new file mode 100644
index 00000000000..5422c5d9aa3
--- /dev/null
+++ b/test/src/e2e_vm_tests/test_programs/s... | good | review_fixed | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
@@ -549,7 +554,107 @@ pub(super) fn compile_entry_function(
panicking_fn_cache: &mut PanickingFunctionCache,
test_decl_ref: Option<DeclRefFunction>,
compiled_fn_cache: &mut CompiledFunctionCache,
+ decls_to_check: &[TyDecl],
) -> Result<Function, Vec<CompileError>> {
+ let mut is_type_trivially_de... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -384,6 +385,7 @@ pub fn compile_program<'a>(
&mut panicking_fn_cache,
&test_fns,
&mut compiled_fn_cache,
+ decls_to_check, | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation.rs b/sway-core/src/ir_generation.rs
index 3ea644068e1..aedfd27ce96 100644
--- a/sway-core/src/ir_generation.rs
+++ b/sway-core/src/ir_generation.rs
@@ -11,7 +11,6 @@ use std::{
collections::HashMap,
hash::{DefaultHasher, Hasher},
};
-
use sway_error::error::CompileEr... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -549,7 +554,107 @@ pub(super) fn compile_entry_function(
panicking_fn_cache: &mut PanickingFunctionCache,
test_decl_ref: Option<DeclRefFunction>,
compiled_fn_cache: &mut CompiledFunctionCache,
+ decls_to_check: &[TyDecl],
) -> Result<Function, Vec<CompileError>> {
+ let mut is_type_trivially_de... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -549,7 +554,107 @@ pub(super) fn compile_entry_function(
panicking_fn_cache: &mut PanickingFunctionCache,
test_decl_ref: Option<DeclRefFunction>,
compiled_fn_cache: &mut CompiledFunctionCache,
+ decls_to_check: &[TyDecl],
) -> Result<Function, Vec<CompileError>> {
+ let mut is_type_trivially_de... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -549,7 +554,107 @@ pub(super) fn compile_entry_function(
panicking_fn_cache: &mut PanickingFunctionCache,
test_decl_ref: Option<DeclRefFunction>,
compiled_fn_cache: &mut CompiledFunctionCache,
+ decls_to_check: &[TyDecl],
) -> Result<Function, Vec<CompileError>> {
+ let mut is_type_trivially_de... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -0,0 +1,41 @@
+---
+source: test/src/snapshot/mod.rs
+---
+> forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require
+exit status: 1 | bad | review | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes/attribute_require/stdout.snap
new file mode 100644
index 00000000000..9a83e15e125
--- /dev/null
+++ b/test/src/e2e_vm_tests/test_programs/s... | good | review_fixed | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
@@ -213,6 +229,7 @@ pub(super) fn compile_contract(
panicking_fn_cache,
None,
compiled_fn_cache,
+ &[], | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -519,10 +519,17 @@ impl CollectTypesMetadata for TyDecl {
return Ok(vec![]);
}
}
+ TyDecl::StructDecl(decl) => {
+ let d = ctx.engines.de().get(&decl.decl_id);
+ if !d.attributes.is_empty() {
+ vec![TypeMet... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/language/ty/declaration/declaration.rs b/sway-core/src/language/ty/declaration/declaration.rs
index f12eeb9fd89..a4888f5c405 100644
--- a/sway-core/src/language/ty/declaration/declaration.rs
+++ b/sway-core/src/language/ty/declaration/declaration.rs
@@ -1,17 +1,17 @@
use crate::{
decl_e... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -5556,11 +5570,26 @@ impl MemoryRepresentation {
pub fn get_runtime_representation(ctx: &Context, t: Type) -> MemoryRepresentation {
match t.get_content(ctx) {
TypeContent::Unit | TypeContent::Never => MemoryRepresentation::And(vec![]),
- TypeContent::Bool => MemoryRepresentation::Blob { len_in... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs
index 2169d4aa07c..79cd8c73610 100644
--- a/sway-core/src/ir_generation/function.rs
+++ b/sway-core/src/ir_generation/function.rs
@@ -28,9 +28,13 @@ use crate::{
types::*,
PanicOccurrence, PanicOccurrences, Panickin... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -6841,3 +6842,186 @@ fn nok_abi_encoding_invalid_bool() {
let actual = encode(2u8);
let _ = abi_decode::<bool>(actual);
}
+
+pub struct TrivialBool {
+ value: u64
+}
+
+impl AbiEncode for TrivialBool {
+ fn is_encode_trivial() -> bool {
+ true
+ }
+
+ fn abi_encode(self, buffer: Buffer)... | bad | review | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw
index 32bb8ef5e88..e5527835fb9 100644
--- a/sway-lib-std/src/codec.sw
+++ b/sway-lib-std/src/codec.sw
@@ -3,6 +3,8 @@ library;
use ::ops::*;
use ::raw_ptr::*;
use ::raw_slice::*;
+use ::slice::*;
+use ::error_signals::*;
pub struct Buffer {
b... | good | review_fixed | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
@@ -173,6 +181,52 @@ fn type_check_encoding_memory_id(
Ok((intrinsic_function, ctx.engines.te().id_of_u64()))
}
+fn type_check_enum_discriminant_count(
+ arguments: &[Expression],
+ handler: &Handler,
+ kind: Intrinsic,
+ type_arguments: &[GenericArgument],
+ span: Span,
+ ctx: TypeCheckContex... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs b/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
index 4666c48f85b..350086a32aa 100644
--- a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
+++ b/sway-core/src/semantic_analysis/a... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -65,6 +65,11 @@ pub const ABI_NAME_NAME_ARG_NAME: &str = "name";
pub const EVENT_ATTRIBUTE_NAME: &str = "event";
pub const INDEXED_ATTRIBUTE_NAME: &str = "indexed";
+// Require Attributes
+pub const REQUIRE_ATTRIBUTE_NAME: &str = "require";
+pub const REQUIRE_ARG_NAME_TRIVIALLY_ENCODABLE: &str = "trivially_encod... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-ast/src/attribute.rs b/sway-ast/src/attribute.rs
index 515d7a43f77..7c26ae939a3 100644
--- a/sway-ast/src/attribute.rs
+++ b/sway-ast/src/attribute.rs
@@ -65,6 +65,11 @@ pub const ABI_NAME_NAME_ARG_NAME: &str = "name";
pub const EVENT_ATTRIBUTE_NAME: &str = "event";
pub const INDEXED_ATTRIBUTE_NAME:... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -576,6 +620,246 @@ pub(super) fn compile_entry_function(
.map(|f| f.expect("entry point should never contain generics"))
}
+fn run_ir_decl_checks(
+ engines: &Engines,
+ context: &mut Context,
+ md_mgr: &mut MetadataManager,
+ module: Module,
+ decls_to_check: &[TyDecl],
+) -> Option<Result<Fu... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -519,10 +519,17 @@ impl CollectTypesMetadata for TyDecl {
return Ok(vec![]);
}
}
+ TyDecl::StructDecl(decl) => {
+ let d = ctx.engines.de().get(&decl.decl_id);
+ if !d.attributes.is_empty() {
+ vec![TypeMet... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/language/ty/declaration/declaration.rs b/sway-core/src/language/ty/declaration/declaration.rs
index f12eeb9fd89..a4888f5c405 100644
--- a/sway-core/src/language/ty/declaration/declaration.rs
+++ b/sway-core/src/language/ty/declaration/declaration.rs
@@ -1,17 +1,17 @@
use crate::{
decl_e... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -1998,6 +1998,9 @@ fn const_eval_intrinsic(
Ok(Some(Constant::unique(lookup.context, c)))
}
+ Intrinsic::EnumDiscriminantCount => {
+ todo!();
+ } | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/const_eval.rs b/sway-core/src/ir_generation/const_eval.rs
index fe5f5613517..86ee30a77f5 100644
--- a/sway-core/src/ir_generation/const_eval.rs
+++ b/sway-core/src/ir_generation/const_eval.rs
@@ -567,44 +567,7 @@ fn const_eval_typed_expr(
fn_ref,
call_p... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -2463,6 +2461,118 @@ impl<'a> FnCompiler<'a> {
context,
))
}
+ Intrinsic::EnumVariantsValues => {
+ assert!(type_arguments.len() == 1);
+ // assert!(arguments.len() >= 1);
+
+ let arg = type_arguments[0].as_typ... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs
index 2169d4aa07c..79cd8c73610 100644
--- a/sway-core/src/ir_generation/function.rs
+++ b/sway-core/src/ir_generation/function.rs
@@ -28,9 +28,13 @@ use crate::{
types::*,
PanicOccurrence, PanicOccurrences, Panickin... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -173,6 +176,85 @@ fn type_check_encoding_memory_id(
Ok((intrinsic_function, ctx.engines.te().id_of_u64()))
}
+fn type_check_enum_variants_values(
+ arguments: &[Expression],
+ handler: &Handler,
+ kind: Intrinsic,
+ type_arguments: &[GenericArgument],
+ span: Span,
+ mut ctx: TypeCheckConte... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs b/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
index 4666c48f85b..350086a32aa 100644
--- a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
+++ b/sway-core/src/semantic_analysis/a... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -6841,3 +6842,207 @@ fn nok_abi_encoding_invalid_bool() {
let actual = encode(2u8);
let _ = abi_decode::<bool>(actual);
}
+
+pub struct TrivialBool {
+ value: u64,
+}
+
+impl AbiEncode for TrivialBool {
+ fn is_encode_trivial() -> bool {
+ true
+ }
+
+ fn abi_encode(self, buffer: Buffer... | bad | review | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw
index 32bb8ef5e88..e5527835fb9 100644
--- a/sway-lib-std/src/codec.sw
+++ b/sway-lib-std/src/codec.sw
@@ -3,6 +3,8 @@ library;
use ::ops::*;
use ::raw_ptr::*;
use ::raw_slice::*;
+use ::slice::*;
+use ::error_signals::*;
pub struct Buffer {
b... | good | review_fixed | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
@@ -173,6 +176,85 @@ fn type_check_encoding_memory_id(
Ok((intrinsic_function, ctx.engines.te().id_of_u64()))
}
+fn type_check_enum_variants_values(
+ arguments: &[Expression],
+ handler: &Handler,
+ kind: Intrinsic,
+ type_arguments: &[GenericArgument],
+ span: Span,
+ mut ctx: TypeCheckConte... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs b/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
index 4666c48f85b..350086a32aa 100644
--- a/sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
+++ b/sway-core/src/semantic_analysis/a... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -6841,3 +6842,210 @@ fn nok_abi_encoding_invalid_bool() {
let actual = encode(2u8);
let _ = abi_decode::<bool>(actual);
}
+
+pub struct TrivialBool {
+ value: u64,
+}
+
+impl AbiEncode for TrivialBool {
+ fn is_encode_trivial() -> bool {
+ true
+ }
+
+ fn abi_encode(self, buffer: Buffer... | bad | review | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw
index 32bb8ef5e88..e5527835fb9 100644
--- a/sway-lib-std/src/codec.sw
+++ b/sway-lib-std/src/codec.sw
@@ -3,6 +3,8 @@ library;
use ::ops::*;
use ::raw_ptr::*;
use ::raw_slice::*;
+use ::slice::*;
+use ::error_signals::*;
pub struct Buffer {
b... | good | review_fixed | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
@@ -261,7 +261,7 @@ pub(crate) fn monomorphize_with_modpath<T>(
subst_ctx: &SubstTypesContext,
) -> Result<(), ErrorEmitted>
where
- T: MonomorphizeHelper + SubstTypes + MaterializeConstGenerics,
+ T: std::fmt::Debug + MonomorphizeHelper + SubstTypes + MaterializeConstGenerics, | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/type_system/monomorphization.rs b/sway-core/src/type_system/monomorphization.rs
index 70871ea15ba..80327e179bb 100644
--- a/sway-core/src/type_system/monomorphization.rs
+++ b/sway-core/src/type_system/monomorphization.rs
@@ -276,12 +276,8 @@ where
subst_ctx,
)?;
- value.su... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -27,6 +27,8 @@ pub(crate) fn instantiate_function_application(
arguments: Option<&[Expression]>,
span: Span,
) -> Result<ty::TyExpression, ErrorEmitted> {
+ //eprintln!("instantiate_function_application: {:?}", function_decl_ref.name()); | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/function_application.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/function_application.rs
index 0f75245398d..288b068983e 100644
--- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/functi... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -576,6 +598,248 @@ pub(super) fn compile_entry_function(
.map(|f| f.expect("entry point should never contain generics"))
}
+pub fn run_ir_decl_checks(
+ engines: &Engines,
+ context: &mut Context,
+ md_mgr: &mut MetadataManager,
+ module: Module,
+ decls_to_check: &[CheckDecl],
+) -> Option<Ve... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -90,6 +93,11 @@ impl CollectTypesMetadata for TypeId {
ctx.call_site_get(self),
));
}
+ TypeInfo::Struct(decl) => {
+ let mut types = TyDecl::StructDecl(StructDecl { decl_id: *decl })
+ .collect_ty... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/type_system/id.rs b/sway-core/src/type_system/id.rs
index 6a17fc1aab6..de6cbd9e75a 100644
--- a/sway-core/src/type_system/id.rs
+++ b/sway-core/src/type_system/id.rs
@@ -12,7 +12,10 @@ use crate::{
DeclEngineGet, DeclEngineGetParsedDecl, DeclEngineInsert, MaterializeConstGenerics,
... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -336,6 +337,58 @@ where
}
}
+ pub(crate) fn generate_tables(
+ &mut self,
+ engines: &Engines,
+ decl: &TyDecl,
+ ) -> Option<TyAstNode> {
+ let handler = Handler::default();
+ let Ok(enum_decl_id) = decl.to_enum_id(&handler, engines) else {
+ retur... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/auto_impl/abi_encoding.rs b/sway-core/src/semantic_analysis/ast_node/declaration/auto_impl/abi_encoding.rs
index 6a7ab2ce415..ffc797b4774 100644
--- a/sway-core/src/semantic_analysis/ast_node/declaration/auto_impl/abi_encoding.rs
+++ b/sway-core/src/sema... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -576,6 +575,284 @@ pub(super) fn compile_entry_function(
.map(|f| f.expect("entry point should never contain generics"))
}
+#[derive(Debug, Clone)]
+pub enum CheckDecl {
+ Ref {
+ tid: TypeId,
+ is_decode_trivial_table: HashMap<String, TyExpression>,
+ type_name_span: Span,
+ },
+ ... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -1050,6 +1080,180 @@ pub fn parsed_to_ast(
Ok(typed_program)
}
+fn run_decl_checks(
+ handler: &Handler,
+ typed_program: &ty::TyProgram,
+ type_check_ctx: &mut TypeCheckContext<'_>,
+ ir_ctx: &mut Context<'_>,
+ md_mgr: &mut MetadataManager,
+ module: Module,
+) {
+ let mut decl_checks ... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs
index 9a1c701bccc..9cffb101efb 100644
--- a/sway-core/src/lib.rs
+++ b/sway-core/src/lib.rs
@@ -26,11 +26,18 @@ pub mod source_map;
pub mod transform;
pub mod type_system;
+use crate::decl_engine::DeclEngineGet as _;
+use crate::engine_threading::SpannedWithE... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -1008,14 +1037,15 @@ pub fn parsed_to_ast(
});
}
+ let mut md_mgr = MetadataManager::default(); | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs
index 9a1c701bccc..9cffb101efb 100644
--- a/sway-core/src/lib.rs
+++ b/sway-core/src/lib.rs
@@ -26,11 +26,18 @@ pub mod source_map;
pub mod transform;
pub mod type_system;
+use crate::decl_engine::DeclEngineGet as _;
+use crate::engine_threading::SpannedWithE... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -2937,3 +2938,221 @@ fn nok_abi_encoding_invalid_bool() {
let actual = encode(2u8);
let _ = abi_decode::<bool>(actual);
}
+
+pub struct TrivialBool {
+ value: u64,
+}
+
+impl AbiEncode for TrivialBool {
+ fn is_encode_trivial() -> bool {
+ true
+ }
+
+ fn abi_encode(self, buffer: Buffer... | bad | review | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw
index 32bb8ef5e88..e5527835fb9 100644
--- a/sway-lib-std/src/codec.sw
+++ b/sway-lib-std/src/codec.sw
@@ -3,6 +3,8 @@ library;
use ::ops::*;
use ::raw_ptr::*;
use ::raw_slice::*;
+use ::slice::*;
+use ::error_signals::*;
pub struct Buffer {
b... | good | review_fixed | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 | |
@@ -1050,6 +1078,195 @@ pub fn parsed_to_ast(
Ok(typed_program)
}
+fn run_decl_checks(
+ handler: &Handler,
+ typed_program: &ty::TyProgram,
+ type_check_ctx: &mut TypeCheckContext<'_>,
+ ir_ctx: &mut Context<'_>,
+ md_mgr: &mut MetadataManager,
+ module: Module,
+) {
+ let mut decl_checks ... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs
index 9a1c701bccc..9cffb101efb 100644
--- a/sway-core/src/lib.rs
+++ b/sway-core/src/lib.rs
@@ -26,11 +26,18 @@ pub mod source_map;
pub mod transform;
pub mod type_system;
+use crate::decl_engine::DeclEngineGet as _;
+use crate::engine_threading::SpannedWithE... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -576,6 +575,300 @@ pub(super) fn compile_entry_function(
.map(|f| f.expect("entry point should never contain generics"))
}
+#[derive(Debug, Clone)]
+pub enum CheckDecl {
+ Ref {
+ tid: TypeId,
+ is_decode_trivial_table: HashMap<String, TyExpression>,
+ type_name_span: Span,
+ },
+ ... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -576,6 +575,300 @@ pub(super) fn compile_entry_function(
.map(|f| f.expect("entry point should never contain generics"))
}
+#[derive(Debug, Clone)]
+pub enum CheckDecl {
+ Ref {
+ tid: TypeId,
+ is_decode_trivial_table: HashMap<String, TyExpression>,
+ type_name_span: Span,
+ },
+ ... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/compile.rs b/sway-core/src/ir_generation/compile.rs
index 1a2b95e9ae3..153d420b6c8 100644
--- a/sway-core/src/ir_generation/compile.rs
+++ b/sway-core/src/ir_generation/compile.rs
@@ -1,32 +1,42 @@
+use super::{
+ const_eval::{compile_const_decl, LookupEnv},
+ convert::con... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -501,6 +502,8 @@ pub enum CompileError {
},
#[error("This opcode takes an immediate value but none was provided.")]
MissingImmediate { span: Span },
+ #[error("Invalid argument.")]
+ InvalidArgument { span: Span }, | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-error/src/error.rs b/sway-error/src/error.rs
index 97d77fe44de..c4693cecfbc 100644
--- a/sway-error/src/error.rs
+++ b/sway-error/src/error.rs
@@ -9,6 +9,7 @@ use crate::parser_error::{ParseError, ParseErrorKind};
use crate::type_error::TypeError;
use core::fmt;
+use std::collections::BTreeSet;
u... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -820,42 +820,49 @@ pub(crate) fn prepare_const_generics_materialization<'a>(
type_parameters.any(|x| matches!(x, TypeParameter::Const(_)));
if has_const_generic_parameters {
- let a = engines.te().get(param_types.next().unwrap());
- let b = engines.te().get(args_types.next().unwrap());
... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs
index b15c620e47c..2b06d55297a 100644
--- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_app... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -5220,26 +5232,89 @@ impl<'a> FnCompiler<'a> {
}
}
- let index_val = return_on_termination_or_extract!(
- self.compile_expression_to_register(context, md_mgr, index_expr)?
- )
- .expect_register();
-
- let elem_type = array_type.get_array_elem_type(conte... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs
index 2169d4aa07c..79cd8c73610 100644
--- a/sway-core/src/ir_generation/function.rs
+++ b/sway-core/src/ir_generation/function.rs
@@ -28,9 +28,13 @@ use crate::{
types::*,
PanicOccurrence, PanicOccurrences, Panickin... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -61,7 +61,7 @@ fn resolve_length(
let decl = match resolved_decl {
TyDecl::ConstGenericDecl(decl) => ConstGenericExprTyDecl::ConstGenericDecl(decl),
TyDecl::ConstantDecl(decl) => ConstGenericExprTyDecl::ConstantDecl(decl),
- _ => unreachable!(),
+ ... | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/semantic_analysis/type_resolve.rs b/sway-core/src/semantic_analysis/type_resolve.rs
index 317d73925b2..f760a4cfbae 100644
--- a/sway-core/src/semantic_analysis/type_resolve.rs
+++ b/sway-core/src/semantic_analysis/type_resolve.rs
@@ -61,7 +61,11 @@ fn resolve_length(
let decl = m... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -469,6 +472,7 @@ impl Attribute {
AbiName => Multiplicity::exactly(1),
Event => Multiplicity::zero(),
Indexed => Multiplicity::zero(),
+ Require => Multiplicity::at_most(2), | bad | review | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
diff --git a/sway-core/src/transform/attribute.rs b/sway-core/src/transform/attribute.rs
index fd144d75441..1cb764ecb54 100644
--- a/sway-core/src/transform/attribute.rs
+++ b/sway-core/src/transform/attribute.rs
@@ -358,6 +358,7 @@ pub enum AttributeKind {
AbiName,
Event,
Indexed,
+ Require,
}
//... | good | review_fixed | rust | FuelLabs/sway | 094041d5f9a37889918e867ae39e6addba61f3c4 |
@@ -0,0 +1,121 @@
+script;
+
+fn main(trivial: Vec<u64>, non_trivial: Vec<u32>) -> (Vec<u64>, Vec<u32>) {
+ assert_eq(trivial.len(), 3);
+ assert_eq(trivial.get(0).unwrap_or(0), 124);
+ assert_eq(trivial.get(1).unwrap_or(0), 124);
+ assert_eq(trivial.get(2).unwrap_or(0), 124);
+
+ let mut trivial = Vec::... | bad | review | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/src/main.sw
new file mode 100644
index 00000000000..dbb392a42fa
--- /dev/null
+++ b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/... | good | review_fixed | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
@@ -0,0 +1,4 @@
+category = "run"
+
+script_data_new_encoding = "0000000000000003000000000000007c000000000000007c000000000000007c 00000000000000030000007c0000007c0000007c"
+expected_result_new_encoding = { action = "return_data", value = "0000000000000006000000000000007c000000000000007c000000000000007c000000000000007c0... | bad | review | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/test.run.toml b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/vec_encoding_decoding/test.run.toml
new file mode 100644
index 00000000000..e3e7741a9ab
--- /dev/null
+++ b/test/src/e2e_vm_tests/test_programs/should_pass/std... | good | review_fixed | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
@@ -933,3 +944,71 @@ where
l.finish();
}
}
+
+struct NonTrivial { | bad | review | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
diff --git a/sway-lib-std/src/vec.sw b/sway-lib-std/src/vec.sw
index c0f0c94a96b..0071e496ac8 100644
--- a/sway-lib-std/src/vec.sw
+++ b/sway-lib-std/src/vec.sw
@@ -1,7 +1,7 @@
//! A vector type for dynamically sized arrays outside of storage.
library;
-use ::alloc::{alloc, realloc};
+use ::alloc::{alloc, alloc_byt... | good | review_fixed | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
@@ -933,3 +944,71 @@ where
l.finish();
}
}
+
+struct NonTrivial {
+ v: u64,
+}
+
+impl AbiEncode for NonTrivial {
+ fn is_encode_trivial() -> bool {
+ false
+ }
+
+ fn abi_encode(self, buffer: Buffer) -> Buffer {
+ self.v.abi_encode(buffer)
+ }
+}
+
+impl AbiDecode for NonTri... | bad | review | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
diff --git a/sway-lib-std/src/vec.sw b/sway-lib-std/src/vec.sw
index c0f0c94a96b..0071e496ac8 100644
--- a/sway-lib-std/src/vec.sw
+++ b/sway-lib-std/src/vec.sw
@@ -1,7 +1,7 @@
//! A vector type for dynamically sized arrays outside of storage.
library;
-use ::alloc::{alloc, realloc};
+use ::alloc::{alloc, alloc_byt... | good | review_fixed | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
@@ -933,3 +944,71 @@ where
l.finish();
}
}
+
+struct NonTrivial {
+ v: u64,
+}
+
+impl AbiEncode for NonTrivial {
+ fn is_encode_trivial() -> bool {
+ false
+ }
+
+ fn abi_encode(self, buffer: Buffer) -> Buffer {
+ self.v.abi_encode(buffer)
+ }
+}
+
+impl AbiDecode for NonTri... | bad | review | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 | |
diff --git a/sway-lib-std/src/vec.sw b/sway-lib-std/src/vec.sw
index c0f0c94a96b..0071e496ac8 100644
--- a/sway-lib-std/src/vec.sw
+++ b/sway-lib-std/src/vec.sw
@@ -1,7 +1,7 @@
//! A vector type for dynamically sized arrays outside of storage.
library;
-use ::alloc::{alloc, realloc};
+use ::alloc::{alloc, alloc_byt... | good | review_fixed | FuelLabs/sway | 2a991efd623ecab749d2a36791ec55e3dfafeb62 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.