diff --git a/docs/book/src/basics/constants.md b/docs/book/src/basics/constants.md index d5d8a48413b..97427836f0c 100644 --- a/docs/book/src/basics/constants.md +++ b/docs/book/src/basics/constants.md @@ -2,11 +2,13 @@ + Constants are similar to variables; however, there are a few differences: - Constants are always evaluated at compile-time. - Constants can be declared both inside of a [function](../index.md) and at global / `impl` scope. - The `mut` keyword cannot be used with constants. +- Constants must contain a [type annotation](./variables.md#type-annotations). ```sway @@ -31,19 +33,21 @@ fn arr_wrapper(a: u64, b: u64, c: u64) -> [u64; 3] { [a, b, c] } -const ARR2 = arr_wrapper(bool_to_num(1) + 42, 2, 3); +const ARR2: [u64; 3] = arr_wrapper(bool_to_num(1) + 42, 2, 3); ``` ## Associated Constants + Associated constants are constants associated with a type and can be declared in an `impl` block or in a `trait` definition. Associated constants declared inside a `trait` definition may omit their initializers to indicate that each implementation of the trait must specify those initializers. The identifier is the name of the constant used in the path. The type is the type that the definition has to implement. + You can _define_ an associated `const` directly in the interface surface of a trait: @@ -102,7 +106,9 @@ fn main() -> u64 { + Configurable constants are special constants that behave like regular constants in the sense that they cannot change during program execution, but they can be configured _after_ the Sway program has been built. The Rust and TS SDKs allow updating the values of these constants by injecting new values for them directly in the bytecode without having to build the program again. These are useful for contract factories and behave somewhat similarly to `immutable` variables from languages like Solidity. + Configurable constants are declared inside a `configurable` block and require a type ascription and an initializer as follows: diff --git a/docs/book/src/blockchain-development/calling_contracts.md b/docs/book/src/blockchain-development/calling_contracts.md index 1c10b5ee344..5cbf01d79da 100644 --- a/docs/book/src/blockchain-development/calling_contracts.md +++ b/docs/book/src/blockchain-development/calling_contracts.md @@ -39,7 +39,7 @@ abi ContractB { fn make_call(); } -const contract_id = 0x79fa8779bed2f36c3581d01c79df8da45eee09fac1fd76a5a656e16326317ef0; +const contract_id: b256 = 0x79fa8779bed2f36c3581d01c79df8da45eee09fac1fd76a5a656e16326317ef0; impl ContractB for Contract { fn make_call() { diff --git a/docs/reference/src/code/examples/wallet_example/src/main.sw b/docs/reference/src/code/examples/wallet_example/src/main.sw index cc3052259c1..2c65d5ee496 100644 --- a/docs/reference/src/code/examples/wallet_example/src/main.sw +++ b/docs/reference/src/code/examples/wallet_example/src/main.sw @@ -20,7 +20,7 @@ storage { balance: u64 = 0, } -const OWNER = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); +const OWNER: Address = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); impl Wallet for Contract { #[storage(read, write)] diff --git a/docs/reference/src/code/language/built-ins/constants/src/lib.sw b/docs/reference/src/code/language/built-ins/constants/src/lib.sw index 6e206b27a73..66c9d5769a4 100644 --- a/docs/reference/src/code/language/built-ins/constants/src/lib.sw +++ b/docs/reference/src/code/language/built-ins/constants/src/lib.sw @@ -3,7 +3,7 @@ library; struct S {} impl S { - const ID = 0; + const ID: u64 = 0; } // ANCHOR: id diff --git a/docs/reference/src/code/language/program-types/libraries/internal/my_lib/src/my_library.sw b/docs/reference/src/code/language/program-types/libraries/internal/my_lib/src/my_library.sw index 54a521161ba..7fa7c658fc1 100644 --- a/docs/reference/src/code/language/program-types/libraries/internal/my_lib/src/my_library.sw +++ b/docs/reference/src/code/language/program-types/libraries/internal/my_lib/src/my_library.sw @@ -7,7 +7,7 @@ library; fn foo() {} // Can import everything below because they are using the `pub` keyword -pub const ONE = __to_str_array("1"); +pub const ONE: str[1] = __to_str_array("1"); pub struct MyStruct {} diff --git a/docs/reference/src/code/language/style-guide/letter_casing/src/lib.sw b/docs/reference/src/code/language/style-guide/letter_casing/src/lib.sw index 4987bd809f3..3bfcc949395 100644 --- a/docs/reference/src/code/language/style-guide/letter_casing/src/lib.sw +++ b/docs/reference/src/code/language/style-guide/letter_casing/src/lib.sw @@ -2,7 +2,7 @@ library; // ANCHOR_END: module // ANCHOR: const -const MAXIMUM_DEPOSIT = 10; +const MAXIMUM_DEPOSIT: u64 = 10; // ANCHOR_END: const // ANCHOR: structures struct MultiSignatureWallet { diff --git a/docs/reference/src/code/language/variables/src/lib.sw b/docs/reference/src/code/language/variables/src/lib.sw index 47a12293d28..2b0a4a2110d 100644 --- a/docs/reference/src/code/language/variables/src/lib.sw +++ b/docs/reference/src/code/language/variables/src/lib.sw @@ -47,6 +47,6 @@ fn shadowing() { fn constants() { // ANCHOR: constants - const FOO = 5; + const FOO: u64 = 5; // ANCHOR_END: constants } diff --git a/docs/reference/src/code/operations/call_data/src/lib.sw b/docs/reference/src/code/operations/call_data/src/lib.sw index de43050d0e6..d0a9dd14a84 100644 --- a/docs/reference/src/code/operations/call_data/src/lib.sw +++ b/docs/reference/src/code/operations/call_data/src/lib.sw @@ -9,7 +9,7 @@ use std::context::msg_amount; // ANCHOR_END: import_amount // ANCHOR: access_control -const OWNER = Identity::Address(Address::from(0x0000000000000000000000000000000000000000000000000000000000000000)); +const OWNER: Identity = Identity::Address(Address::from(0x0000000000000000000000000000000000000000000000000000000000000000)); fn update() { require(msg_sender().unwrap() == OWNER, "Owner Only"); diff --git a/examples/hashing/src/main.sw b/examples/hashing/src/main.sw index 2023bc7a433..2cfdece6c7d 100644 --- a/examples/hashing/src/main.sw +++ b/examples/hashing/src/main.sw @@ -35,7 +35,7 @@ impl Hash for Person { } } -const VALUE_A = 0x9280359a3b96819889d30614068715d634ad0cf9bba70c0f430a8c201138f79f; +const VALUE_A: b256 = 0x9280359a3b96819889d30614068715d634ad0cf9bba70c0f430a8c201138f79f; enum Location { Earth: (), diff --git a/examples/msg_sender/src/main.sw b/examples/msg_sender/src/main.sw index e850b19ee5e..3da7bab08d9 100644 --- a/examples/msg_sender/src/main.sw +++ b/examples/msg_sender/src/main.sw @@ -4,7 +4,7 @@ abi MyOwnedContract { fn receive(field_1: u64) -> bool; } -const OWNER = Address::from(0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c); +const OWNER: Address = Address::from(0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c); impl MyOwnedContract for Contract { fn receive(field_1: u64) -> bool { diff --git a/examples/wallet_smart_contract/src/main.sw b/examples/wallet_smart_contract/src/main.sw index 5ab406a6f3c..512775dafa0 100644 --- a/examples/wallet_smart_contract/src/main.sw +++ b/examples/wallet_smart_contract/src/main.sw @@ -6,7 +6,7 @@ use std::{asset::transfer, call_frames::msg_asset_id, context::msg_amount}; // ANCHOR: abi_import use wallet_abi::Wallet; // ANCHOR_END: abi_import -const OWNER_ADDRESS = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); +const OWNER_ADDRESS: Address = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); storage { balance: u64 = 0, diff --git a/sway-core/src/ir_generation/const_eval.rs b/sway-core/src/ir_generation/const_eval.rs index 9c5d0bd3714..2f04fb920e2 100644 --- a/sway-core/src/ir_generation/const_eval.rs +++ b/sway-core/src/ir_generation/const_eval.rs @@ -1871,13 +1871,13 @@ mod tests { // Code blocks that can be converted to constants assert_is_constant(true, "", "{ 1 }"); assert_is_constant(true, "", "{ let a = 1; a }"); - assert_is_constant(true, "", "{ const a = 1; a }"); + assert_is_constant(true, "", "{ const a: u64 = 1; a }"); assert_is_constant(true, "", "{ struct A {} 1 }"); assert_is_constant(true, "fn id(x: u64) -> u64 { { let x = 2; }; x }", "id(1)"); // Code blocks that cannot be converted to constants assert_is_constant(false, "", "{ let a = 1; }"); - assert_is_constant(false, "", "{ const a = 1; }"); + assert_is_constant(false, "", "{ const a: u64 = 1; }"); assert_is_constant(false, "", "{ struct A {} }"); assert_is_constant(false, "", "{ return 1; 1 }"); assert_is_constant(false, "", "{ }"); diff --git a/sway-core/src/transform/to_parsed_lang/convert_parse_tree.rs b/sway-core/src/transform/to_parsed_lang/convert_parse_tree.rs index dba9159332b..01781266b11 100644 --- a/sway-core/src/transform/to_parsed_lang/convert_parse_tree.rs +++ b/sway-core/src/transform/to_parsed_lang/convert_parse_tree.rs @@ -27,8 +27,11 @@ use sway_ast::{ PathTypeSegment, Pattern, PatternStructField, PubToken, Punctuated, QualifiedPathRoot, Statement, StatementLet, Submodule, TraitType, Traits, Ty, TypeField, UseTree, WhereClause, }; -use sway_error::handler::{ErrorEmitted, Handler}; use sway_error::{convert_parse_tree_error::ConvertParseTreeError, error::CompileError}; +use sway_error::{ + handler::{ErrorEmitted, Handler}, + warning::{CompileWarning, Warning}, +}; use sway_features::ExperimentalFeatures; use sway_types::{integer_bits::IntegerBits, BaseIdent}; use sway_types::{Ident, Span, Spanned}; @@ -1033,6 +1036,10 @@ pub(crate) fn item_const_to_constant_declaration( let type_ascription = match item_const.ty_opt { Some((_colon_token, ty)) => ty_to_type_argument(context, handler, engines, ty)?, None => { + handler.emit_warn(CompileWarning { + span: span.clone(), + warning_content: Warning::ExpectedTypeAnnotationForConstants, + }); if expr.is_none() { let err = ConvertParseTreeError::ConstantRequiresTypeAscription { span: span.clone() }; diff --git a/sway-error/src/warning.rs b/sway-error/src/warning.rs index e73ae7f6484..00c4029c114 100644 --- a/sway-error/src/warning.rs +++ b/sway-error/src/warning.rs @@ -148,6 +148,7 @@ pub enum Warning { last_occurrence: Span, previous_occurrences: Vec, }, + ExpectedTypeAnnotationForConstants, } /// Elements that can be deprecated. @@ -319,6 +320,10 @@ impl fmt::Display for Warning { format!(" {} times", num_to_str(previous_occurrences.len())) } ), + ExpectedTypeAnnotationForConstants => write!( + f, + "This constant lacks a type annotation." + ), } } } diff --git a/sway-lib-std/src/constants.sw b/sway-lib-std/src/constants.sw index 5812a5c87c8..96dabca4dd5 100644 --- a/sway-lib-std/src/constants.sw +++ b/sway-lib-std/src/constants.sw @@ -19,7 +19,7 @@ use ::primitives::*; /// } /// ``` #[deprecated(note = "Please use `b256::zero()`.")] -pub const ZERO_B256 = 0x0000000000000000000000000000000000000000000000000000000000000000; +pub const ZERO_B256: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000; /// A u256 of zero value. /// @@ -37,7 +37,7 @@ pub const ZERO_B256 = 0x00000000000000000000000000000000000000000000000000000000 /// } /// ``` #[deprecated(note = "Please use `u256::zero()`.")] -pub const ZERO_U256 = 0x00u256; +pub const ZERO_U256: u256 = 0x00u256; /// The default Sub Id for assets. /// @@ -51,4 +51,4 @@ pub const ZERO_U256 = 0x00u256; /// assert(AssetId::new(contract_id(), DEFAULT_SUB_ID) == msg_asset_id()); /// } /// ``` -pub const DEFAULT_SUB_ID = b256::zero(); +pub const DEFAULT_SUB_ID: b256 = b256::zero(); diff --git a/sway-lib-std/src/error_signals.sw b/sway-lib-std/src/error_signals.sw index 87f86699378..625bc537128 100644 --- a/sway-lib-std/src/error_signals.sw +++ b/sway-lib-std/src/error_signals.sw @@ -6,39 +6,39 @@ library; /// # Additional Information /// /// The value is: 18446744073709486080 -pub const FAILED_REQUIRE_SIGNAL = 0xffff_ffff_ffff_0000; +pub const FAILED_REQUIRE_SIGNAL: u64 = 0xffff_ffff_ffff_0000; /// A revert with this value signals that it was caused by a failing call to `std::asset::transfer_to_address`. /// /// # Additional Information /// /// The value is: 18446744073709486081 -pub const FAILED_TRANSFER_TO_ADDRESS_SIGNAL = 0xffff_ffff_ffff_0001; +pub const FAILED_TRANSFER_TO_ADDRESS_SIGNAL: u64 = 0xffff_ffff_ffff_0001; /// A revert with this value signals that it was caused by a failing call to `std::assert::assert_eq`. /// /// # Additional Information /// /// The value is: 18446744073709486083 -pub const FAILED_ASSERT_EQ_SIGNAL = 0xffff_ffff_ffff_0003; +pub const FAILED_ASSERT_EQ_SIGNAL: u64 = 0xffff_ffff_ffff_0003; /// A revert with this value signals that it was caused by a failing call to `std::assert::assert`. /// /// # Additional Information /// /// The value is: 18446744073709486084 -pub const FAILED_ASSERT_SIGNAL = 0xffff_ffff_ffff_0004; +pub const FAILED_ASSERT_SIGNAL: u64 = 0xffff_ffff_ffff_0004; /// A revert with this value signals that it was caused by a failing call to `std::assert::assert_ne`. /// /// # Additional Information /// /// The value is: 18446744073709486085 -pub const FAILED_ASSERT_NE_SIGNAL = 0xffff_ffff_ffff_0005; +pub const FAILED_ASSERT_NE_SIGNAL: u64 = 0xffff_ffff_ffff_0005; /// A revert with this value signals that it was caused by a call to `std::revert::revert_with_log`. /// /// # Additional Information /// /// The value is: 18446744073709486086 -pub const REVERT_WITH_LOG_SIGNAL = 0xffff_ffff_ffff_0006; +pub const REVERT_WITH_LOG_SIGNAL: u64 = 0xffff_ffff_ffff_0006; diff --git a/sway-lib-std/src/inputs.sw b/sway-lib-std/src/inputs.sw index d973d4fd7a9..3ded1ae1745 100644 --- a/sway-lib-std/src/inputs.sw +++ b/sway-lib-std/src/inputs.sw @@ -27,31 +27,31 @@ use ::codec::*; use ::raw_slice::*; // GTF Opcode const selectors -pub const GTF_INPUT_TYPE = 0x200; -// pub const GTF_INPUT_COIN_TX_ID = 0x201; -// pub const GTF_INPUT_COIN_OUTPUT_INDEX = 0x202; -pub const GTF_INPUT_COIN_OWNER = 0x203; -pub const GTF_INPUT_COIN_AMOUNT = 0x204; -pub const GTF_INPUT_COIN_ASSET_ID = 0x205; -pub const GTF_INPUT_COIN_WITNESS_INDEX = 0x207; -pub const GTF_INPUT_COIN_PREDICATE_LENGTH = 0x209; -pub const GTF_INPUT_COIN_PREDICATE_DATA_LENGTH = 0x20A; -pub const GTF_INPUT_COIN_PREDICATE = 0x20B; -pub const GTF_INPUT_COIN_PREDICATE_DATA = 0x20C; -// pub const GTF_INPUT_COIN_PREDICATE_GAS_USED = 0x20D; -// pub const GTF_INPUT_CONTRACT_CONTRACT_ID = 0x225; -pub const GTF_INPUT_MESSAGE_SENDER = 0x240; -pub const GTF_INPUT_MESSAGE_RECIPIENT = 0x241; -pub const GTF_INPUT_MESSAGE_AMOUNT = 0x242; -pub const GTF_INPUT_MESSAGE_NONCE = 0x243; -pub const GTF_INPUT_MESSAGE_WITNESS_INDEX = 0x244; -pub const GTF_INPUT_MESSAGE_DATA_LENGTH = 0x245; -pub const GTF_INPUT_MESSAGE_PREDICATE_LENGTH = 0x246; -pub const GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH = 0x247; -pub const GTF_INPUT_MESSAGE_DATA = 0x248; -pub const GTF_INPUT_MESSAGE_PREDICATE = 0x249; -pub const GTF_INPUT_MESSAGE_PREDICATE_DATA = 0x24A; -// pub const GTF_INPUT_MESSAGE_PREDICATE_GAS_USED = 0x24B; +pub const GTF_INPUT_TYPE: u64 = 0x200; +// pub const GTF_INPUT_COIN_TX_ID: u64 = 0x201; +// pub const GTF_INPUT_COIN_OUTPUT_INDEX: u64 = 0x202; +pub const GTF_INPUT_COIN_OWNER: u64 = 0x203; +pub const GTF_INPUT_COIN_AMOUNT: u64 = 0x204; +pub const GTF_INPUT_COIN_ASSET_ID: u64 = 0x205; +pub const GTF_INPUT_COIN_WITNESS_INDEX: u64 = 0x207; +pub const GTF_INPUT_COIN_PREDICATE_LENGTH: u64 = 0x209; +pub const GTF_INPUT_COIN_PREDICATE_DATA_LENGTH: u64 = 0x20A; +pub const GTF_INPUT_COIN_PREDICATE: u64 = 0x20B; +pub const GTF_INPUT_COIN_PREDICATE_DATA: u64 = 0x20C; +// pub const GTF_INPUT_COIN_PREDICATE_GAS_USED: u64 = 0x20D; +// pub const GTF_INPUT_CONTRACT_CONTRACT_ID: u64 = 0x225; +pub const GTF_INPUT_MESSAGE_SENDER: u64 = 0x240; +pub const GTF_INPUT_MESSAGE_RECIPIENT: u64 = 0x241; +pub const GTF_INPUT_MESSAGE_AMOUNT: u64 = 0x242; +pub const GTF_INPUT_MESSAGE_NONCE: u64 = 0x243; +pub const GTF_INPUT_MESSAGE_WITNESS_INDEX: u64 = 0x244; +pub const GTF_INPUT_MESSAGE_DATA_LENGTH: u64 = 0x245; +pub const GTF_INPUT_MESSAGE_PREDICATE_LENGTH: u64 = 0x246; +pub const GTF_INPUT_MESSAGE_PREDICATE_DATA_LENGTH: u64 = 0x247; +pub const GTF_INPUT_MESSAGE_DATA: u64 = 0x248; +pub const GTF_INPUT_MESSAGE_PREDICATE: u64 = 0x249; +pub const GTF_INPUT_MESSAGE_PREDICATE_DATA: u64 = 0x24A; +// pub const GTF_INPUT_MESSAGE_PREDICATE_GAS_USED: u64 = 0x24B; /// The input type for a transaction. pub enum Input { diff --git a/sway-lib-std/src/outputs.sw b/sway-lib-std/src/outputs.sw index 9f721a55d1d..16c7c6f2cb1 100644 --- a/sway-lib-std/src/outputs.sw +++ b/sway-lib-std/src/outputs.sw @@ -25,18 +25,18 @@ use ::codec::*; // GTF Opcode const selectors // -pub const GTF_OUTPUT_TYPE = 0x300; -pub const GTF_OUTPUT_COIN_TO = 0x301; -pub const GTF_OUTPUT_COIN_AMOUNT = 0x302; -pub const GTF_OUTPUT_COIN_ASSET_ID = 0x303; -// pub const GTF_OUTPUT_CONTRACT_INPUT_INDEX = 0x304; -// pub const GTF_OUTPUT_CONTRACT_BALANCE_ROOT = 0x305; -// pub const GTF_OUTPUT_CONTRACT_STATE_ROOT = 0x306; -// pub const GTF_OUTPUT_CONTRACT_CREATED_CONTRACT_ID = 0x307; -// pub const GTF_OUTPUT_CONTRACT_CREATED_STATE_ROOT = 0x308; +pub const GTF_OUTPUT_TYPE: u64 = 0x300; +pub const GTF_OUTPUT_COIN_TO: u64 = 0x301; +pub const GTF_OUTPUT_COIN_AMOUNT: u64 = 0x302; +pub const GTF_OUTPUT_COIN_ASSET_ID: u64 = 0x303; +// pub const GTF_OUTPUT_CONTRACT_INPUT_INDEX: u64 = 0x304; +// pub const GTF_OUTPUT_CONTRACT_BALANCE_ROOT: u64 = 0x305; +// pub const GTF_OUTPUT_CONTRACT_STATE_ROOT: u64 = 0x306; +// pub const GTF_OUTPUT_CONTRACT_CREATED_CONTRACT_ID: u64 = 0x307; +// pub const GTF_OUTPUT_CONTRACT_CREATED_STATE_ROOT: u64 = 0x308; -const OUTPUT_VARIABLE_ASSET_ID_OFFSET = 48; -const OUTPUT_VARIABLE_TO_OFFSET = 8; +const OUTPUT_VARIABLE_ASSET_ID_OFFSET: u64 = 48; +const OUTPUT_VARIABLE_TO_OFFSET: u64 = 8; /// The output type for a transaction. pub enum Output { diff --git a/sway-lib-std/src/tx.sw b/sway-lib-std/src/tx.sw index 650e8c1e1fb..41b2a8d36c0 100644 --- a/sway-lib-std/src/tx.sw +++ b/sway-lib-std/src/tx.sw @@ -9,40 +9,40 @@ use ::codec::*; // GTF Opcode const selectors // -pub const GTF_TYPE = 0x001; -pub const GTF_SCRIPT_GAS_LIMIT = 0x002; -pub const GTF_SCRIPT_SCRIPT_LENGTH = 0x003; -pub const GTF_SCRIPT_SCRIPT_DATA_LENGTH = 0x004; -pub const GTF_SCRIPT_INPUTS_COUNT = 0x005; -pub const GTF_SCRIPT_OUTPUTS_COUNT = 0x006; -pub const GTF_SCRIPT_WITNESSES_COUNT = 0x007; -pub const GTF_SCRIPT_SCRIPT = 0x009; -pub const GTF_SCRIPT_SCRIPT_DATA = 0x00A; -pub const GTF_SCRIPT_INPUT_AT_INDEX = 0x00B; -pub const GTF_SCRIPT_OUTPUT_AT_INDEX = 0x00C; -pub const GTF_SCRIPT_WITNESS_AT_INDEX = 0x00D; - -pub const GTF_TX_LENGTH = 0x00E; - -// pub const GTF_CREATE_BYTECODE_WITNESS_INDEX = 0x101; -// pub const GTF_CREATE_STORAGE_SLOTS_COUNT = 0x102; -pub const GTF_CREATE_INPUTS_COUNT = 0x103; -pub const GTF_CREATE_OUTPUTS_COUNT = 0x104; -pub const GTF_CREATE_WITNESSES_COUNT = 0x105; -// pub const GTF_CREATE_SALT = 0x106; -// pub const GTF_CREATE_STORAGE_SLOT_AT_INDEX = 0x107; -pub const GTF_CREATE_INPUT_AT_INDEX = 0x108; -pub const GTF_CREATE_OUTPUT_AT_INDEX = 0x109; -pub const GTF_CREATE_WITNESS_AT_INDEX = 0x10A; - -pub const GTF_WITNESS_DATA_LENGTH = 0x400; -pub const GTF_WITNESS_DATA = 0x401; - -pub const GTF_POLICY_TYPES = 0x500; -pub const GTF_POLICY_TIP = 0x501; -pub const GTF_POLICY_WITNESS_LIMIT = 0x502; -pub const GTF_POLICY_MATURITY = 0x503; -pub const GTF_POLICY_MAX_FEE = 0x504; +pub const GTF_TYPE: u64 = 0x001; +pub const GTF_SCRIPT_GAS_LIMIT: u64 = 0x002; +pub const GTF_SCRIPT_SCRIPT_LENGTH: u64 = 0x003; +pub const GTF_SCRIPT_SCRIPT_DATA_LENGTH: u64 = 0x004; +pub const GTF_SCRIPT_INPUTS_COUNT: u64 = 0x005; +pub const GTF_SCRIPT_OUTPUTS_COUNT: u64 = 0x006; +pub const GTF_SCRIPT_WITNESSES_COUNT: u64 = 0x007; +pub const GTF_SCRIPT_SCRIPT: u64 = 0x009; +pub const GTF_SCRIPT_SCRIPT_DATA: u64 = 0x00A; +pub const GTF_SCRIPT_INPUT_AT_INDEX: u64 = 0x00B; +pub const GTF_SCRIPT_OUTPUT_AT_INDEX: u64 = 0x00C; +pub const GTF_SCRIPT_WITNESS_AT_INDEX: u64 = 0x00D; + +pub const GTF_TX_LENGTH: u64 = 0x00E; + +// pub const GTF_CREATE_BYTECODE_WITNESS_INDEX: u64 = 0x101; +// pub const GTF_CREATE_STORAGE_SLOTS_COUNT: u64 = 0x102; +pub const GTF_CREATE_INPUTS_COUNT: u64 = 0x103; +pub const GTF_CREATE_OUTPUTS_COUNT: u64 = 0x104; +pub const GTF_CREATE_WITNESSES_COUNT: u64 = 0x105; +// pub const GTF_CREATE_SALT: u64 = 0x106; +// pub const GTF_CREATE_STORAGE_SLOT_AT_INDEX: u64 = 0x107; +pub const GTF_CREATE_INPUT_AT_INDEX: u64 = 0x108; +pub const GTF_CREATE_OUTPUT_AT_INDEX: u64 = 0x109; +pub const GTF_CREATE_WITNESS_AT_INDEX: u64 = 0x10A; + +pub const GTF_WITNESS_DATA_LENGTH: u64 = 0x400; +pub const GTF_WITNESS_DATA: u64 = 0x401; + +pub const GTF_POLICY_TYPES: u64 = 0x500; +pub const GTF_POLICY_TIP: u64 = 0x501; +pub const GTF_POLICY_WITNESS_LIMIT: u64 = 0x502; +pub const GTF_POLICY_MATURITY: u64 = 0x503; +pub const GTF_POLICY_MAX_FEE: u64 = 0x504; /// A transaction type. pub enum Transaction { @@ -545,7 +545,7 @@ pub fn tx_script_bytecode_hash() -> Option { } } -const TX_ID_OFFSET = 0; +const TX_ID_OFFSET: u64 = 0; /// Get the Transaction ID of the current transaction. /// diff --git a/sway-lsp/tests/fixtures/diagnostics/dead_code/src/main.sw b/sway-lsp/tests/fixtures/diagnostics/dead_code/src/main.sw index 4a2c33ae480..f29225e6a37 100644 --- a/sway-lsp/tests/fixtures/diagnostics/dead_code/src/main.sw +++ b/sway-lsp/tests/fixtures/diagnostics/dead_code/src/main.sw @@ -11,7 +11,7 @@ impl MyContract for Contract { } } -const NOT_USED_NUM = 15; +const NOT_USED_NUM: u64 = 15; const NOT_USED_WITH_TYPE: bool = true; struct NotUsedStruct { a: bool, diff --git a/sway-lsp/tests/fixtures/tokens/consts/src/main.sw b/sway-lsp/tests/fixtures/tokens/consts/src/main.sw index 4c4586e4ca7..2ab9a3f9215 100644 --- a/sway-lsp/tests/fixtures/tokens/consts/src/main.sw +++ b/sway-lsp/tests/fixtures/tokens/consts/src/main.sw @@ -4,10 +4,10 @@ mod more_consts; use more_consts::{Data, Value}; /// documentation for CONSTANT_1 -const CONSTANT_1 = 100; +const CONSTANT_1: u64 = 100; /// CONSTANT_2 has a value of 200 const CONSTANT_2: u32 = 200; -const BASE_TOKEN = ContractId::from(0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c); +const BASE_TOKEN: ContractId = ContractId::from(0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c); const MY_DATA: Data = Data::B(Value {a: 100}); const EXAMPLE: Option> = Option::None; diff --git a/sway-lsp/tests/fixtures/tokens/matches/src/main.sw b/sway-lsp/tests/fixtures/tokens/matches/src/main.sw index 3379f2cb75e..50f39df882a 100644 --- a/sway-lsp/tests/fixtures/tokens/matches/src/main.sw +++ b/sway-lsp/tests/fixtures/tokens/matches/src/main.sw @@ -8,7 +8,7 @@ enum ExampleEnum { Variants: u32, } -const EXAMPLE_CONST = 0; +const EXAMPLE_CONST: u64 = 0; fn main() { let _ = match 0 { diff --git a/sway-lsp/tests/lib.rs b/sway-lsp/tests/lib.rs index 9e61745c6f0..e3a2ec698ac 100644 --- a/sway-lsp/tests/lib.rs +++ b/sway-lsp/tests/lib.rs @@ -1162,7 +1162,7 @@ fn go_to_definition_for_consts() { let mut contract_go_to = GotoDefinition { req_uri: &uri, req_line: 9, - req_char: 24, + req_char: 36, def_line: 12, def_start_char: 11, def_end_char: 21, @@ -1171,7 +1171,7 @@ fn go_to_definition_for_consts() { lsp::definition_check(&server, &contract_go_to).await; // value: `from` - contract_go_to.req_char = 34; + contract_go_to.req_char = 46; contract_go_to.def_line = 62; contract_go_to.def_start_char = 7; contract_go_to.def_end_char = 11; diff --git a/swayfmt/tests/mod.rs b/swayfmt/tests/mod.rs index c9276e42cc0..0fcba9a8716 100644 --- a/swayfmt/tests/mod.rs +++ b/swayfmt/tests/mod.rs @@ -2120,15 +2120,15 @@ fn bug_whitespace_added_after_comment() { library; // GTF Opcode const selectors // - pub const GTF_OUTPUT_TYPE = 0x300; - pub const GTF_OUTPUT_COIN_TO = 0x301; - pub const GTF_OUTPUT_COIN_AMOUNT = 0x302; - pub const GTF_OUTPUT_COIN_ASSET_ID = 0x303; - // pub const GTF_OUTPUT_CONTRACT_INPUT_INDEX = 0x304; - // pub const GTF_OUTPUT_CONTRACT_BALANCE_ROOT = 0x305; - // pub const GTF_OUTPUT_CONTRACT_STATE_ROOT = 0x306; - // pub const GTF_OUTPUT_CONTRACT_CREATED_CONTRACT_ID = 0x307; - // pub const GTF_OUTPUT_CONTRACT_CREATED_STATE_ROOT = 0x308; + pub const GTF_OUTPUT_TYPE: u64 = 0x300; + pub const GTF_OUTPUT_COIN_TO: u64 = 0x301; + pub const GTF_OUTPUT_COIN_AMOUNT: u64 = 0x302; + pub const GTF_OUTPUT_COIN_ASSET_ID: u64 = 0x303; + // pub const GTF_OUTPUT_CONTRACT_INPUT_INDEX: u64 = 0x304; + // pub const GTF_OUTPUT_CONTRACT_BALANCE_ROOT: u64 = 0x305; + // pub const GTF_OUTPUT_CONTRACT_STATE_ROOT: u64 = 0x306; + // pub const GTF_OUTPUT_CONTRACT_CREATED_CONTRACT_ID: u64 = 0x307; + // pub const GTF_OUTPUT_CONTRACT_CREATED_STATE_ROOT: u64 = 0x308; @@ -2152,15 +2152,15 @@ fn bug_whitespace_added_after_comment() { library; // GTF Opcode const selectors // - pub const GTF_OUTPUT_TYPE = 0x300; - pub const GTF_OUTPUT_COIN_TO = 0x301; - pub const GTF_OUTPUT_COIN_AMOUNT = 0x302; - pub const GTF_OUTPUT_COIN_ASSET_ID = 0x303; - // pub const GTF_OUTPUT_CONTRACT_INPUT_INDEX = 0x304; - // pub const GTF_OUTPUT_CONTRACT_BALANCE_ROOT = 0x305; - // pub const GTF_OUTPUT_CONTRACT_STATE_ROOT = 0x306; - // pub const GTF_OUTPUT_CONTRACT_CREATED_CONTRACT_ID = 0x307; - // pub const GTF_OUTPUT_CONTRACT_CREATED_STATE_ROOT = 0x308; + pub const GTF_OUTPUT_TYPE: u64 = 0x300; + pub const GTF_OUTPUT_COIN_TO: u64 = 0x301; + pub const GTF_OUTPUT_COIN_AMOUNT: u64 = 0x302; + pub const GTF_OUTPUT_COIN_ASSET_ID: u64 = 0x303; + // pub const GTF_OUTPUT_CONTRACT_INPUT_INDEX: u64 = 0x304; + // pub const GTF_OUTPUT_CONTRACT_BALANCE_ROOT: u64 = 0x305; + // pub const GTF_OUTPUT_CONTRACT_STATE_ROOT: u64 = 0x306; + // pub const GTF_OUTPUT_CONTRACT_CREATED_CONTRACT_ID: u64 = 0x307; + // pub const GTF_OUTPUT_CONTRACT_CREATED_STATE_ROOT: u64 = 0x308; /// The output type for a transaction. pub enum Output { diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/Forc.lock b/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/Forc.lock new file mode 100644 index 00000000000..684acec4858 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/Forc.lock @@ -0,0 +1,3 @@ +[[package]] +name = "abi_associated_const_missing_expr" +source = "member" diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/Forc.toml b/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/Forc.toml new file mode 100644 index 00000000000..e18e5267966 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/Forc.toml @@ -0,0 +1,6 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" +name = "abi_associated_const_missing_expr" +implicit-std = false diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/src/main.sw new file mode 100644 index 00000000000..d35783f0e3e --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/src/main.sw @@ -0,0 +1,7 @@ +library; + +abi ConstantId { + const ID: u64; +} + +impl ConstantId for Contract { const ID: u64; } diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/test.toml new file mode 100644 index 00000000000..574fb1d8e18 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_fail/abi_associated_const_missing_expr/test.toml @@ -0,0 +1,3 @@ +category = "fail" + +# check: $()Constant requires expression. diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/associated_type_not_in_trait/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/associated_type_not_in_trait/src/main.sw index 5a1f41599ba..5ea7ddc206b 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/associated_type_not_in_trait/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/associated_type_not_in_trait/src/main.sw @@ -1,4 +1,4 @@ script; trait Trait{} struct Struct0{} -impl Trait for Struct0{type u;const u=0;} \ No newline at end of file +impl Trait for Struct0{type u;const u:u64=0;} \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/const_block_level_no_expr/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/const_block_level_no_expr/src/main.sw index 30c0c042230..1a73c9b726e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/const_block_level_no_expr/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/const_block_level_no_expr/src/main.sw @@ -1,6 +1,6 @@ library; fn main() -> u64 { - const X; + const X: u64; 0 } diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/const_block_level_no_expr/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/const_block_level_no_expr/test.toml index 35bf69ce835..cfcd47a5f02 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/const_block_level_no_expr/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_fail/const_block_level_no_expr/test.toml @@ -1,6 +1,6 @@ category = "fail" -# check: $()const X; +# check: $()const X: u64; # nextln: $()Constant requires expression. # check: $()1 error. diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/const_instead_of_let/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/const_instead_of_let/src/main.sw index ed327ce6488..13e9b807195 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/const_instead_of_let/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/const_instead_of_let/src/main.sw @@ -10,7 +10,7 @@ abi Abi2{ pub fn main() { let contract_1 = abi(Abi1, b256::min()); - const INVALID_CONST = contract_1.foo(); + const INVALID_CONST: b256 = contract_1.foo(); let contract_2 = abi(Abi2, INVALID_CONST); let _ = contract_2.bar(); } diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/const_instead_of_let/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/const_instead_of_let/test.toml index 437aba233ee..f71c71cbd61 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/const_instead_of_let/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_fail/const_instead_of_let/test.toml @@ -1,7 +1,7 @@ category = "fail" # check: $()error -# check: $()const INVALID_CONST = contract_1.foo(); +# check: $()const INVALID_CONST: b256 = contract_1.foo(); # nextln: $()Could not evaluate initializer to a const declaration. # check: $()Aborting due to 1 error diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/const_top_level_no_expr/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/const_top_level_no_expr/src/main.sw index 2bf19b3ff3f..8e70885745a 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/const_top_level_no_expr/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/const_top_level_no_expr/src/main.sw @@ -1,3 +1,3 @@ library; -const X; +const X: u64; diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/const_top_level_no_expr/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/const_top_level_no_expr/test.toml index 35bf69ce835..cfcd47a5f02 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/const_top_level_no_expr/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_fail/const_top_level_no_expr/test.toml @@ -1,6 +1,6 @@ category = "fail" -# check: $()const X; +# check: $()const X: u64; # nextln: $()Constant requires expression. # check: $()1 error. diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/deduplication_of_shadowing_errors/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/deduplication_of_shadowing_errors/src/main.sw index b1e8af99707..28b4b60dacb 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/deduplication_of_shadowing_errors/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/deduplication_of_shadowing_errors/src/main.sw @@ -7,7 +7,7 @@ use lib::Struct; use lib::Struct; use lib::Struct; -const X = 0; +const X: u64 = 0; fn main() -> () { let X = 1; @@ -15,11 +15,11 @@ fn main() -> () { let y = 3; { - const y = 4; + const y: u64 = 4; } { - const y = 6; + const y: u64 = 6; } } diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/deduplication_of_shadowing_errors/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/deduplication_of_shadowing_errors/test.toml index 968be6793f5..712527253a6 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/deduplication_of_shadowing_errors/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_fail/deduplication_of_shadowing_errors/test.toml @@ -17,12 +17,12 @@ category = "fail" #check: $()Constants cannot shadow variables #nextln: $()main.sw:18 -#check: $()const y = 4; +#check: $()const y: u64 = 4; #nextln: $()Constant "y" shadows variable of the same name. #check: $()Constants cannot shadow variables #nextln: $()main.sw:22 -#check: $()const y = 6; +#check: $()const y: u64 = 6; #nextln: $()Constant "y" shadows variable of the same name. #check: $()Constants cannot be shadowed diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/different_contract_caller_types/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/different_contract_caller_types/src/main.sw index 1c68ee97b32..9fd0bee509f 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/different_contract_caller_types/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/different_contract_caller_types/src/main.sw @@ -1,6 +1,6 @@ script; -const ADDRESS = 0x1234123412341234123412341234123412341234123412341234123412341234; +const ADDRESS: b256 = 0x1234123412341234123412341234123412341234123412341234123412341234; fn main() -> u64 { let caller: ContractCaller = contract_caller(); diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/error_const/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/error_const/src/main.sw index 0daabc68ec7..28409a9df49 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/error_const/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/error_const/src/main.sw @@ -1,3 +1,3 @@ library; -const p={/); +const p:()={/); diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/error_const/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/error_const/test.toml index 9d1043c6647..440b71cae1f 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/error_const/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_fail/error_const/test.toml @@ -1,18 +1,18 @@ category = "fail" -# check: $()const p={/); +# check: $()const p:()={/); # nextln: $()Constant "p" should be SCREAMING_SNAKE_CASE. -# check: $()const p={/); +# check: $()const p:()={/); # nextln: $()This declaration is never used. -# check: $()const p={/); +# check: $()const p:()={/); # nextln: $()mismatched delimiters -# check: $()const p={/); +# check: $()const p:()={/); # nextln: $()Expected an expression. -# check: $()const p={/); +# check: $()const p:()={/); # nextln: $()Could not evaluate initializer to a const declaration. # check: $()Aborting due to 3 errors. diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/generics_not_supported/src/lib_a/inner_lib.sw b/test/src/e2e_vm_tests/test_programs/should_fail/generics_not_supported/src/lib_a/inner_lib.sw index f9f6d400104..21ca36b8b4a 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/generics_not_supported/src/lib_a/inner_lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/generics_not_supported/src/lib_a/inner_lib.sw @@ -1,6 +1,6 @@ library; -pub const C = 42; +pub const C: u64 = 42; pub fn func() -> bool { true diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_2.sw index 1fa9465b0ec..86b95b1ca0d 100755 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { W: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_3.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_3.sw index c836a3b99dd..60309c0941e 100755 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_3.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_3.sw @@ -14,7 +14,7 @@ pub enum Items3_Variants { V: u64, } -pub const ITEMS_3_FUNCTION_RES = 3872; +pub const ITEMS_3_FUNCTION_RES: u64 = 3872; pub fn items_3_function() -> u64 { ITEMS_3_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_4.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_4.sw index 5c297e872ab..d07bd4690e8 100755 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_4.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/aliases/src/items_4.sw @@ -14,7 +14,7 @@ pub enum Items4_Variants { T: u64, } -pub const ITEMS_4_FUNCTION_RES = 14278; +pub const ITEMS_4_FUNCTION_RES: u64 = 14278; pub fn items_4_function() -> u64 { ITEMS_4_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/multiple_imports_of_same_reexport/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/multiple_imports_of_same_reexport/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/multiple_imports_of_same_reexport/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/multiple_imports_of_same_reexport/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_1.sw index 95b236919b7..b55c8caa650 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_1.sw @@ -9,7 +9,7 @@ pub enum Items1_Enum { B: bool, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> bool { ITEMS_1_FUNCTION_RES == 456 diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_2_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_2_1.sw index f00aa5f00c7..ff4f4241fcb 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_2_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_2_1.sw @@ -9,7 +9,7 @@ pub enum Items2_Enum { D: bool, } -pub const ITEMS_2_FUNCTION_RES = 789; +pub const ITEMS_2_FUNCTION_RES: u64 = 789; pub fn items_2_function() -> bool { ITEMS_2_FUNCTION_RES == 789 diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_2_2.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_2_2.sw index 6822e86d865..4dfd9875229 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_2_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_2_2.sw @@ -9,7 +9,7 @@ pub enum Items2_Enum { D: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_3_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_3_1.sw index 86138d9e3ed..021cd0f64ee 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_3_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_3_1.sw @@ -14,7 +14,7 @@ pub enum Items3_Variants { H: bool, } -pub const ITEMS_3_FUNCTION_RES = 1234; +pub const ITEMS_3_FUNCTION_RES: u64 = 1234; pub fn items_3_function() -> bool { ITEMS_3_FUNCTION_RES == 1234 diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_4_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_4_1.sw index 2d9be57fc13..40835091d78 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_4_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_4_1.sw @@ -14,7 +14,7 @@ pub enum Items4_Variants { L: bool, } -pub const ITEMS_4_FUNCTION_RES = 5678; +pub const ITEMS_4_FUNCTION_RES: u64 = 5678; pub fn items_4_function() -> bool { ITEMS_4_FUNCTION_RES == 5678 diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_4_2.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_4_2.sw index d57d5b3fbc6..debb7bd3e34 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_4_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/items_4_2.sw @@ -14,7 +14,7 @@ pub enum Items4_Variants { L: u64, } -pub const ITEMS_4_FUNCTION_RES = 8765; +pub const ITEMS_4_FUNCTION_RES: u64 = 8765; pub fn items_4_function() -> u64 { ITEMS_4_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/lib_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/lib_1.sw index 783403a1e47..661be00eaba 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/lib_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/lib_1.sw @@ -11,7 +11,7 @@ enum Items1_Enum { B: u64, } -const ITEMS_1_FUNCTION_RES = 654; +const ITEMS_1_FUNCTION_RES: u64 = 654; fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/lib_3.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/lib_3.sw index 6ed081d11ef..c8625081523 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/lib_3.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/shadowing_in_reexporting_module/src/lib_3.sw @@ -17,7 +17,7 @@ enum Items3_Variants { H: u64, } -const ITEMS_3_FUNCTION_RES = 4321; +const ITEMS_3_FUNCTION_RES: u64 = 4321; fn items_3_function() -> u64 { ITEMS_3_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_glob_import/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_glob_import/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_glob_import/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_glob_import/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_glob_import/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_glob_import/src/items_2.sw index 654a63ac267..54346f66779 100755 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_glob_import/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_glob_import/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { P: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_item_import/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_item_import/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_item_import/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_item_import/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_item_import/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_item_import/src/items_2.sw index 654a63ac267..54346f66779 100755 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_item_import/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_item_import/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { P: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_path_access/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_path_access/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_path_access/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_path_access/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_path_access/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_path_access/src/items_2.sw index 250723123de..a85913da383 100755 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_path_access/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/reexport/simple_path_access/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { P: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/references/references_to_mutable_values/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/language/references/references_to_mutable_values/src/main.sw index fdb23ee4366..ac0ad8e8b38 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/references/references_to_mutable_values/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/references/references_to_mutable_values/src/main.sw @@ -5,14 +5,14 @@ mod lib; use ::lib::LIB_X; use ::lib::LIB_X as LIB_X_ALIAS; -const LOCAL_X = 123; +const LOCAL_X: u64 = 123; struct S { x: u8, } impl S { - const X = 0; + const X: u64 = 0; } struct S2 { diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_configurables/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_configurables/src/lib.sw index 1b41f86d27d..0a194afb983 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_configurables/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_configurables/src/lib.sw @@ -1,7 +1,7 @@ library; -pub const LIB_X = 5; +pub const LIB_X: u64 = 5; -pub const LIB_Y = 5; +pub const LIB_Y: u64 = 5; -pub const LIB_Z = 5; +pub const LIB_Z: u64 = 5; diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/src/lib.sw index f8c6cf92999..5565d91491c 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/src/lib.sw @@ -1,15 +1,15 @@ library; -pub const L_A = 5; +pub const L_A: u64 = 5; -pub const L_X = 5; +pub const L_X: u64 = 5; -pub const L_Y = 5; +pub const L_Y: u64 = 5; -pub const L_Z = 5; +pub const L_Z: u64 = 5; -pub const L_K = 5; +pub const L_K: u64 = 5; -pub const L_M = 5; +pub const L_M: u64 = 5; -pub const L_N = 5; +pub const L_N: u64 = 5; diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/src/main.sw index c70856944ff..41aabe88a1f 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/src/main.sw @@ -8,15 +8,15 @@ use lib::L_A; // module const shadowing an imported const use lib::L_X; -const L_X = 1; +const L_X: u64 = 1; // module const shadowing a module const -const M_X = 2; -const M_X = 3; +const M_X: u64 = 2; +const M_X: u64 = 3; -const M_Y = 4; +const M_Y: u64 = 4; -const M_Z = 41; +const M_Z: u64 = 41; use lib::L_Y; use lib::L_Z; @@ -31,26 +31,26 @@ struct StructWithConstNames { fn main() { // local const shadowing a module const - const M_Y = 5; + const M_Y: u64 = 5; { - const M_Y = 55; + const M_Y: u64 = 55; } // local const shadowing a const imported in module - const L_Y = 6; + const L_Y: u64 = 6; // local const shadowing a local const - const F_X = 7; - const F_X = 8; + const F_X: u64 = 7; + const F_X: u64 = 8; { - const F_X = 81; + const F_X: u64 = 81; } { // scoped local const shadowing a scoped local const - const F_Y = 9; + const F_Y: u64 = 9; { - const F_Y = 10; + const F_Y: u64 = 10; } } @@ -61,12 +61,12 @@ fn main() { } // variable shadowing a local const - const F_Z = 11; + const F_Z: u64 = 11; let F_Z = 102; // local const shadowing a variable let F_A = 103; - const F_A = 12; + const F_A: u64 = 12; // variable shadowing a variable - this is okay! let A = 104; @@ -83,10 +83,10 @@ fn main() { let B = 108; { // scoped const shadowing a variable - const B = 13; + const B: u64 = 13; } - const F_K = 14; + const F_K: u64 = 14; { // scoped variable shadowing a local const let F_K = 109; @@ -103,7 +103,7 @@ fn main() { // const shadowing a locally imported const use lib::L_M; - const L_M = 15; + const L_M: u64 = 15; let s = StructWithConstNames { M_X, @@ -121,38 +121,38 @@ fn main() { use lib::L_N; -const M_M = 16; +const M_M: u64 = 16; struct S { } impl S { - const S_X = 200; - const S_X = 201; + const S_X: u64 = 200; + const S_X: u64 = 201; - const L_N = 202; + const L_N: u64 = 202; - const M_M = 203; + const M_M: u64 = 203; - const S_Y = 204; + const S_Y: u64 = 204; fn f() { - const S_Y = 205; + const S_Y: u64 = 205; } } enum E { } impl E { - const E_X = 300; - const E_X = 301; + const E_X: u64 = 300; + const E_X: u64 = 301; - const L_N = 302; + const L_N: u64 = 302; - const M_M = 303; + const M_M: u64 = 303; - const E_Y = 304; + const E_Y: u64 = 304; fn f() { - const E_Y = 305; + const E_Y: u64 = 305; } } diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/test.toml index 163d6285a55..14efc62251f 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars/test.toml @@ -9,70 +9,70 @@ category = "fail" #sameln: $()Constant of the same name already exists #check: $()use lib::L_X; #nextln: $()Constant "L_X" is already declared here. -#check: $()const L_X = 1; +#check: $()const L_X: u64 = 1; #nextln: $()Constant "L_X" has the same name as an already declared constant. #check: $()error #sameln: $()Constant of the same name already exists -#check: $()const M_X = 2; +#check: $()const M_X: u64 = 2; #nextln: $()Constant "M_X" is already declared here. -#nextln: $()const M_X = 3; +#nextln: $()const M_X: u64 = 3; #nextln: $()Constant "M_X" has the same name as an already declared constant. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const M_Y = 4; +#check: $()const M_Y: u64 = 4; #nextln: $()Shadowed constant "M_Y" is declared here. -#check: $()const M_Y = 5; +#check: $()const M_Y: u64 = 5; #nextln: $()Constant "M_Y" shadows constant of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const M_Y = 5; +#check: $()const M_Y: u64 = 5; #nextln: $()Shadowed constant "M_Y" is declared here. -#check: $()const M_Y = 55; +#check: $()const M_Y: u64 = 55; #nextln: $()Constant "M_Y" shadows constant of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const M_Y = 4; +#check: $()const M_Y: u64 = 4; #nextln: $()Shadowed constant "M_Y" is declared here. -#check: $()const M_Y = 55; +#check: $()const M_Y: u64 = 55; #nextln: $()Constant "M_Y" shadows constant of the same name. #check: $()error #sameln: $()Constants cannot be shadowed #check: $()use lib::L_Y; #nextln: $()Shadowed constant "L_Y" gets imported here. -#check: $()const L_Y = 6; +#check: $()const L_Y: u64 = 6; #nextln: $()Constant "L_Y" shadows imported constant of the same name. -#check: $()pub const L_Y = 5; +#check: $()pub const L_Y: u64 = 5; #nextln: $()This is the original declaration of the imported constant "L_Y". #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const F_X = 7; +#check: $()const F_X: u64 = 7; #nextln: $()Shadowed constant "F_X" is declared here. -#nextln: $()const F_X = 8; +#nextln: $()const F_X: u64 = 8; #nextln: $()Constant "F_X" shadows constant of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const F_X = 7; +#check: $()const F_X: u64 = 7; #nextln: $()Shadowed constant "F_X" is declared here. -#check: $()const F_X = 81; +#check: $()const F_X: u64 = 81; #nextln: $()Constant "F_X" shadows constant of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const F_Y = 9; +#check: $()const F_Y: u64 = 9; #nextln: $()Shadowed constant "F_Y" is declared here. -#check: $()const F_Y = 10; +#check: $()const F_Y: u64 = 10; #nextln: $()Constant "F_Y" shadows constant of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const L_X = 1; +#check: $()const L_X: u64 = 1; #nextln: $()Shadowed constant "L_X" is declared here. #check: $()let L_X = 100; #nextln: $()Variable "L_X" shadows constant of the same name. @@ -83,12 +83,12 @@ category = "fail" #nextln: $()Shadowed constant "L_X" gets imported here. #check: $()let L_X = 100; #nextln: $()Variable "L_X" shadows imported constant of the same name. -#check: $()pub const L_X = 5; +#check: $()pub const L_X: u64 = 5; #nextln: $()This is the original declaration of the imported constant "L_X". #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const L_X = 1; +#check: $()const L_X: u64 = 1; #nextln: $()Shadowed constant "L_X" is declared here. #check: $()let L_X = 101; #nextln: $()Variable "L_X" shadows constant of the same name. @@ -99,12 +99,12 @@ category = "fail" #nextln: $()Shadowed constant "L_X" gets imported here. #check: $()let L_X = 101; #nextln: $()Variable "L_X" shadows imported constant of the same name. -#check: $()pub const L_X = 5; +#check: $()pub const L_X: u64 = 5; #nextln: $()This is the original declaration of the imported constant "L_X". #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const F_Z = 11; +#check: $()const F_Z: u64 = 11; #nextln: $()Shadowed constant "F_Z" is declared here. #nextln: $()let F_Z = 102; #nextln: $()Variable "F_Z" shadows constant of the same name. @@ -113,26 +113,26 @@ category = "fail" #sameln: $()Constants cannot shadow variables #check: $()let F_A = 103; #nextln: $()This is the shadowed variable "F_A". -#nextln: $()const F_A = 12; +#nextln: $()const F_A: u64 = 12; #nextln: $()Constant "F_A" shadows variable of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const M_Y = 5; +#check: $()const M_Y: u64 = 5; #nextln: $()Shadowed constant "M_Y" is declared here. #check: $()let M_Y = 106; #nextln: $()Variable "M_Y" shadows constant of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const M_Y = 4; +#check: $()const M_Y: u64 = 4; #nextln: $()Shadowed constant "M_Y" is declared here. #check: $()let M_Y = 106; #nextln: $()Variable "M_Y" shadows constant of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const M_Z = 41; +#check: $()const M_Z: u64 = 41; #nextln: $()Shadowed constant "M_Z" is declared here. #check: $()let M_Z = 107; #nextln: $()Variable "M_Z" shadows constant of the same name. @@ -141,12 +141,12 @@ category = "fail" #sameln: $()Constants cannot shadow variables #check: $()let B = 108; #nextln: $()This is the shadowed variable "B". -#check: $()const B = 13; +#check: $()const B: u64 = 13; #nextln: $()Constant "B" shadows variable of the same name. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const F_K = 14; +#check: $()const F_K: u64 = 14; #nextln: $()Shadowed constant "F_K" is declared here. #check: $()let F_K = 109; #nextln: $()Variable "F_K" shadows constant of the same name. @@ -157,7 +157,7 @@ category = "fail" #nextln: $()Shadowed constant "L_Z" gets imported here. #check: $()let L_Z = 110; #nextln: $()Variable "L_Z" shadows imported constant of the same name. -#check: $()pub const L_Z = 5; +#check: $()pub const L_Z: u64 = 5; #nextln: $()This is the original declaration of the imported constant "L_Z". #check: $()error @@ -166,21 +166,21 @@ category = "fail" #nextln: $()Shadowed constant "L_K" gets imported here. #check: $()let L_K = 111; #nextln: $()Variable "L_K" shadows imported constant of the same name. -#check: $()pub const L_K = 5; +#check: $()pub const L_K: u64 = 5; #nextln: $()This is the original declaration of the imported constant "L_K". #check: $()error #sameln: $()Constants cannot be shadowed #check: $()use lib::L_M; #nextln: $()Shadowed constant "L_M" gets imported here. -#check: $()const L_M = 15; +#check: $()const L_M: u64 = 15; #nextln: $()Constant "L_M" shadows imported constant of the same name. -#check: $()pub const L_M = 5; +#check: $()pub const L_M: u64 = 5; #nextln: $()This is the original declaration of the imported constant "L_M". #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const M_X = 2; +#check: $()const M_X: u64 = 2; #nextln: $()Shadowed constant "M_X" is declared here. #check: $()StructWithConstNames { M_X, L_Y, L_Z_ALIAS } => { #nextln: $()Variable "M_X" shadows constant of the same name. @@ -191,7 +191,7 @@ category = "fail" #nextln: $()Shadowed constant "L_Y" gets imported here. #check: $()StructWithConstNames { M_X, L_Y, L_Z_ALIAS } => { #nextln: $()Variable "L_Y" shadows imported constant of the same name. -#check: $()pub const L_Y = 5; +#check: $()pub const L_Y: u64 = 5; #nextln: $()This is the original declaration of the imported constant "L_Y". #check: $()error @@ -200,61 +200,61 @@ category = "fail" #nextln: $()Shadowed constant "L_Z_ALIAS" gets imported here as alias. #check: $()StructWithConstNames { M_X, L_Y, L_Z_ALIAS } => { #nextln: $()Variable "L_Z_ALIAS" shadows imported constant of the same name. -#check: $()pub const L_Z = 5; +#check: $()pub const L_Z: u64 = 5; #nextln: $()This is the original declaration of the imported constant "L_Z_ALIAS". #check: $()error #sameln: $()Constant of the same name already exists -#check: $()const S_X = 200; +#check: $()const S_X: u64 = 200; #nextln: $()Constant "S_X" is already declared here. -#check: $()const S_X = 201; +#check: $()const S_X: u64 = 201; #nextln: $()Constant "S_X" has the same name as an already declared constant. #check: $()error #sameln: $()Constant of the same name already exists #check: $()use lib::L_N; #nextln: $()Constant "L_N" is already declared here. -#check: $()const L_N = 202; +#check: $()const L_N: u64 = 202; #nextln: $()Constant "L_N" has the same name as an already declared constant. #check: $()error #sameln: $()Constant of the same name already exists -#check: $()const M_M = 16; +#check: $()const M_M: u64 = 16; #nextln: $()Constant "M_M" is already declared here. -#check: $()const M_M = 203; +#check: $()const M_M: u64 = 203; #nextln: $()Constant "M_M" has the same name as an already declared constant. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const S_Y = 204; +#check: $()const S_Y: u64 = 204; #nextln: $()Shadowed constant "S_Y" is declared here. -#check: $()const S_Y = 205; +#check: $()const S_Y: u64 = 205; #nextln: $()Constant "S_Y" shadows constant of the same name. #check: $()error #sameln: $()Constant of the same name already exists -#check: $()const E_X = 300; +#check: $()const E_X: u64 = 300; #nextln: $()Constant "E_X" is already declared here. -#check: $()const E_X = 301; +#check: $()const E_X: u64 = 301; #nextln: $()Constant "E_X" has the same name as an already declared constant. #check: $()error #sameln: $()Constant of the same name already exists #check: $()use lib::L_N; #nextln: $()Constant "L_N" is already declared here. -#check: $()const L_N = 302; +#check: $()const L_N: u64 = 302; #nextln: $()Constant "L_N" has the same name as an already declared constant. #check: $()error #sameln: $()Constant of the same name already exists -#check: $()const M_M = 16; +#check: $()const M_M: u64 = 16; #nextln: $()Constant "M_M" is already declared here. -#check: $()const M_M = 303; +#check: $()const M_M: u64 = 303; #nextln: $()Constant "M_M" has the same name as an already declared constant. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const E_Y = 304; +#check: $()const E_Y: u64 = 304; #nextln: $()Shadowed constant "E_Y" is declared here. -#check: $()const E_Y = 305; +#check: $()const E_Y: u64 = 305; #nextln: $()Constant "E_Y" shadows constant of the same name. \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/src/lib.sw index fe4e38b6508..c6ab1786cef 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/src/lib.sw @@ -1,7 +1,7 @@ library; -pub const X = 5; +pub const X: u64 = 5; -pub const L = 5; +pub const L: u64 = 5; -pub const P = 5; +pub const P: u64 = 5; diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/src/main.sw index 6343a7f3b3a..9b12a6f8b0e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/src/main.sw @@ -4,7 +4,7 @@ mod lib; // const shadowing an imported const with alias use lib::X as Y; -const Y = 7; +const Y: u64 = 7; use lib::L as M; diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/test.toml b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/test.toml index 47228488d82..48056ece5be 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_fail/shadowing/shadowed_consts_and_vars_alias/test.toml @@ -4,13 +4,13 @@ category = "fail" #sameln: $()Constant of the same name already exists #check: $()use lib::X as Y; #nextln: $()Constant "Y" is already declared here. -#check: $()const Y = 7; +#check: $()const Y: u64 = 7; #nextln: $()Constant "Y" has the same name as an already declared constant. #check: $()error #sameln: $()Constants cannot be shadowed -#check: $()const Y = 7; +#check: $()const Y: u64 = 7; #nextln: $()Shadowed constant "Y" is declared here. #check: $()let Y = 4; @@ -25,7 +25,7 @@ category = "fail" #check: $()let Y = 4; #nextln: $()Variable "Y" shadows imported constant of the same name. -#check: $()pub const X = 5; +#check: $()pub const X: u64 = 5; #nextln: $()This is the original declaration of the imported constant "Y". #check: $()Consider renaming the variable "Y" or using a different alias for the imported constant. @@ -39,7 +39,7 @@ category = "fail" #check: $()let M = 4; #nextln: $()Variable "M" shadows imported constant of the same name. -#check: $()pub const L = 5; +#check: $()pub const L: u64 = 5; #nextln: $()This is the original declaration of the imported constant "M". #check: $()Consider renaming the variable "M" or using a different alias for the imported constant. @@ -53,7 +53,7 @@ category = "fail" #check: $()let R = 5; #nextln: $()Variable "R" shadows imported constant of the same name. -#check: $()pub const P = 5; +#check: $()pub const P: u64 = 5; #nextln: $()This is the original declaration of the imported constant "R". #check: $()Consider renaming the variable "R" or using a different alias for the imported constant. diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/dca/allow_dead_code/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/dca/allow_dead_code/src/main.sw index 80b07dd4f27..bad660a45be 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/dca/allow_dead_code/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/dca/allow_dead_code/src/main.sw @@ -1,7 +1,7 @@ script; #[allow(dead_code)] -const A = 1; +const A: u64 = 1; #[allow(dead_code)] struct A { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_decl_expr/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_decl_expr/src/main.sw index 0781d5a169e..d1a413a13f6 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_decl_expr/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_decl_expr/src/main.sw @@ -1,8 +1,8 @@ script; -const C1 = 66; +const C1: u64 = 66; fn main() -> u64 { - const C2 = C1; + const C2: u64 = C1; C2 } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_struct/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_struct/src/main.sw index 13502bd5cf2..aad5b2a7ac2 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_struct/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_struct/src/main.sw @@ -8,7 +8,7 @@ fn foo(a : u64) -> A { A { a } } -const B : A = foo(32); +const B: A = foo(32); fn main() -> u64 { B.a diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_struct/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_struct/test.toml index cd3ba5361eb..927a6c2d18e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_struct/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_struct/test.toml @@ -1,4 +1,4 @@ category = "compile" -# not: $()const B : A = foo(32); +# not: $()const B: A = foo(32); # not: $()This declaration is never used. diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_while/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_while/src/main.sw index 8007752ead4..3b3ab814cef 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_while/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_while/src/main.sw @@ -1,6 +1,6 @@ script; -const COND = false; +const COND: bool = false; fn main() { while COND { } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_while/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_while/test.toml index 99cf93684a3..bcef7800d39 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_while/test.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/dca/constant_while/test.toml @@ -1,4 +1,4 @@ category = "compile" -# not: $()const COND = false; +# not: $()const COND: bool = false; # not: $()This declaration is never used. diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/associated_type_fully_qualified/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/associated_type_fully_qualified/src/main.sw index db66e79523b..45208866fb7 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/associated_type_fully_qualified/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/associated_type_fully_qualified/src/main.sw @@ -25,7 +25,7 @@ impl TypeTrait2 for Struct { } impl ConstTrait for Struct2 { - const C = 42u64; + const C: u64 = 42u64; } fn main() -> u32 { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/break_and_continue/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/break_and_continue/src/main.sw index 42293fab754..fc1f7609521 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/break_and_continue/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/break_and_continue/src/main.sw @@ -1,6 +1,6 @@ script; -const N = 10; +const N: u64 = 10; fn simple_break_test() { let mut i = 0; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/earth.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/earth.sw index 069ba00a9e8..01b7b119049 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/earth.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/earth.sw @@ -1,3 +1,3 @@ library; -pub const MAN = 5; +pub const MAN: u64 = 5; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/heaven.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/heaven.sw index 32c71548fa5..ed97481d599 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/heaven.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/heaven.sw @@ -1,4 +1,4 @@ library; -pub const UNKNOWN_DEITY_VALUE = 0; -pub const MONKEYS_GONE_HERE = true; +pub const UNKNOWN_DEITY_VALUE: u64 = 0; +pub const MONKEYS_GONE_HERE: bool = true; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/hell.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/hell.sw index 131163599a3..aa86443c02d 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/hell.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_in_library/src/hell.sw @@ -1,3 +1,3 @@ library; -pub const THE_DEVIL = 6; +pub const THE_DEVIL: u64 = 6; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_inits/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_inits/src/main.sw index f007f1270cb..9234eedf3e5 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_inits/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_inits/src/main.sw @@ -1,10 +1,10 @@ script; -const ETH_ID0 = ContractId::from(0x0000000000000000000000000000000000000000000000000000000000000000); +const ETH_ID0: ContractId = ContractId::from(0x0000000000000000000000000000000000000000000000000000000000000000); fn contract_id_wrapper(b: b256) -> ContractId { ContractId::from(b) } -const ETH_ID1 = contract_id_wrapper(0x0000000000000000000000000000000000000000000000000000000000000001); +const ETH_ID1: ContractId = contract_id_wrapper(0x0000000000000000000000000000000000000000000000000000000000000001); // test if-expressions fn bool_to_num(b: bool) -> u64 { @@ -17,14 +17,14 @@ fn bool_to_num(b: bool) -> u64 { // test variable shadowing and local const fn const_42(x: u64) -> u64 { - const forty_two = 42; + const forty_two: u64 = 42; let x: u64 = forty_two; x } // test variable scopes and local const fn id(x: u64) -> u64 { - const forty_two = 42; + const forty_two: u64 = 42; { let x: u64 = forty_two; }; @@ -34,19 +34,19 @@ fn id(x: u64) -> u64 { const QUUX: u64 = id(0); const BAZ: u64 = const_42(123456); -const TUP1 = (2, 1, 21); -const ARR1 = [1, 2, 3]; +const TUP1: (u64, u64, u64) = (2, 1, 21); +const ARR1: [u64; 3] = [1, 2, 3]; fn tup_wrapper(a: u64, b: u64, c: u64) -> (u64, u64, u64) { (a, b, c) } -const TUP2 = tup_wrapper(2, 1, 21); +const TUP2: (u64, u64, u64) = tup_wrapper(2, 1, 21); fn arr_wrapper(a: u64, b: u64, c: u64) -> [u64; 3] { [a, b, c] } -const ARR2 = arr_wrapper(1, 2, 3); +const ARR2: [u64; 3] = arr_wrapper(1, 2, 3); enum En1 { Int: u64, @@ -56,29 +56,29 @@ enum En1 { const X_SIZE: u64 = 4; const Y_SIZE: u64 = 2; -const XPY = ((X_SIZE + Y_SIZE - 1) * 2) / 5; -const EN0A = En1::Int(XPY); +const XPY: u64 = ((X_SIZE + Y_SIZE - 1) * 2) / 5; +const EN0A: En1 = En1::Int(XPY); const TRUEB: bool = X_SIZE == 4; const FALSEB: bool = X_SIZE == Y_SIZE; const TRUEB1: bool = X_SIZE > Y_SIZE; const FALSEB1: bool = X_SIZE < Y_SIZE; -const SO = __size_of::(); -const SOV = __size_of_val("hello"); +const SO: u64 = __size_of::(); +const SOV: u64 = __size_of_val("hello"); -const EN1a = En1::Int(101); -const EN1b = En1::Arr(ARR2); -const EN1c = En1::NoVal; +const EN1a: En1 = En1::Int(101); +const EN1b: En1 = En1::Arr(ARR2); +const EN1c: En1 = En1::NoVal; -const ETH_ID0_VALUE = ETH_ID0.bits(); -const TUP1_idx2 = TUP1.2; +const ETH_ID0_VALUE: b256 = ETH_ID0.bits(); +const TUP1_idx2: u64 = TUP1.2; -const INT1 = 1; +const INT1: u64 = 1; // b256 -const ZERO_B256 = 0x0000000000000000000000000000000000000000000000000000000000000000; -const ONE_B256 = 0x0000000000000000000000000000000000000000000000000000000000000001; -const KEY = ZERO_B256; +const ZERO_B256: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000; +const ONE_B256: b256 = 0x0000000000000000000000000000000000000000000000000000000000000001; +const KEY: b256 = ZERO_B256; const BITWISE_B256: b256 = !ZERO_B256 & ZERO_B256 | ZERO_B256 ^ ZERO_B256; const SHIFT_B256: b256 = ZERO_B256 >> 1 << 1; @@ -90,7 +90,7 @@ const MASK3: u32 = 15; const FOO_MIDDLE: u32 = ((FOO & MASK) | MASK2) ^ MASK3; const OPS: u64 = 10 + 9 - 8 * 7 / 6 << 5 >> 4 ^ 3 | 2 & bool_to_num(true); -const CARR1 = [X_SIZE - Y_SIZE + 1; 4]; +const CARR1: [u64; 4] = [X_SIZE - Y_SIZE + 1; 4]; // This doesn't work because const-eval happens after type-checking, // and the type checker needs to know the size of the array. // const CARR2 = [1; X_SIZE - Y_SIZE + 1]; @@ -105,21 +105,21 @@ impl WithSelf { const WithSelfValue: u64 = WithSelf::size(); fn main() -> u64 { - const int1 = 1; + const int1: u64 = 1; assert(int1 == INT1 && ZERO_B256 == KEY); // initialization through function applications. - const eth_id0 = ContractId::from(0x0000000000000000000000000000000000000000000000000000000000000000); - const eth_id1 = ContractId::from(0x0000000000000000000000000000000000000000000000000000000000000001); + const eth_id0: ContractId = ContractId::from(0x0000000000000000000000000000000000000000000000000000000000000000); + const eth_id1: ContractId = ContractId::from(0x0000000000000000000000000000000000000000000000000000000000000001); assert(eth_id0 == ETH_ID0 && eth_id1 == ETH_ID1); assert(BAZ == 42); assert(QUUX == 0); // tuples and arrays. - const t1 = (2, 1, 21); + const t1: (u64, u64, u64) = (2, 1, 21); assert(t1.0 == TUP1.0 && t1.1 == TUP1.1 && t1.2 == TUP1.2); assert(t1.0 == TUP2.0 && t1.1 == TUP2.1 && t1.2 == TUP2.2); - const a1 = [1, 2, 3]; + const a1: [u64; 3] = [1, 2, 3]; assert(a1[0] == ARR1[0] && a1[1] == ARR1[1] && a1[2] == ARR1[2]); assert(a1[0] == ARR2[0] && a1[1] == ARR2[1] && a1[2] == ARR2[2]); assert( @@ -172,11 +172,11 @@ fn main() -> u64 { 1 } -const NOTA = !0u8; -const NOTB = !0u16; -const NOTC = !0u32; -const NOTD = !0u64; -const NOTE = !false; +const NOTA: u8 = !0u8; +const NOTB: u16 = !0u16; +const NOTC: u32 = !0u32; +const NOTD: u64 = !0u64; +const NOTE: bool = !false; fn test_not() { assert(NOTA == 0xFFu8); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/Forc.lock b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/Forc.lock new file mode 100644 index 00000000000..f0d2a6b29c8 --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/Forc.lock @@ -0,0 +1,3 @@ +[[package]] +name = "const_lacks_type_annotation" +source = "member" diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/Forc.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/Forc.toml new file mode 100644 index 00000000000..1689c57d0ac --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/Forc.toml @@ -0,0 +1,6 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" +name = "const_lacks_type_annotation" +implicit-std = false diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/src/main.sw new file mode 100644 index 00000000000..7813898cece --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/src/main.sw @@ -0,0 +1,3 @@ +library; + +const X = 0; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/test.toml b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/test.toml new file mode 100644 index 00000000000..91e259ec13c --- /dev/null +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_lacks_type_annotation/test.toml @@ -0,0 +1,6 @@ +category = "compile" + +# check: $()const X = 0; +# nextln: $()This constant lacks a type annotation. + +expected_warnings = 2 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/enum_if_let/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/enum_if_let/src/main.sw index bb92fabb834..fbedc35cefb 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/enum_if_let/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/enum_if_let/src/main.sw @@ -1,6 +1,6 @@ script; -const B1 = Address::from(0x0100000000000000000000000000000000000000000000000000000000000010); +const B1: Address = Address::from(0x0100000000000000000000000000000000000000000000000000000000000010); fn main() -> u64 { let a = Result::Ok::(100); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/integer_type_inference/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/integer_type_inference/src/main.sw index 30e2a112a79..8a16dd9c158 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/integer_type_inference/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/integer_type_inference/src/main.sw @@ -13,11 +13,11 @@ const Z2: u32 = 4; const W1: u64 = 4u64; const W2: u64 = 4; -const V1 = 4u8; -const V2 = 4u16; -const V3 = 4u32; -const V4 = 4u64; -const V5 = 4; +const V1: u8 = 4u8; +const V2: u16 = 4u16; +const V3: u32 = 4u32; +const V4: u64 = 4u64; +const V5: u64 = 4; /* Traits Specific to Individual Integer Types */ trait FooU8 { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/transmute/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/transmute/src/main.sw index 9bad6776dcc..7f37315bbdd 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/transmute/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/transmute/src/main.sw @@ -20,21 +20,21 @@ pub struct SomeStruct { fn const_transmute() { // u16 needs 8 bytes as u64 - const U8ARRAY_U16 = __transmute::<[u8; 8], u16>([0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8]); + const U8ARRAY_U16: u16 = __transmute::<[u8; 8], u16>([0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8]); assert(U8ARRAY_U16 == 0x0102u16); // u32 needs 8 bytes as u64 - const U8ARRAY_U32 = __transmute::<[u8; 8], u32>([0u8, 0u8, 0u8, 0u8, 1u8, 2u8, 3u8, 4u8]); + const U8ARRAY_U32: u32 = __transmute::<[u8; 8], u32>([0u8, 0u8, 0u8, 0u8, 1u8, 2u8, 3u8, 4u8]); assert(U8ARRAY_U32 == 0x01020304u32); - const U8ARRAY_U64 = __transmute::<[u8; 8], u64>([1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8]); + const U8ARRAY_U64: u64 = __transmute::<[u8; 8], u64>([1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8]); assert(U8ARRAY_U64 == 0x0102030405060708u64); // u32 <-> u64 - const U32_U64 = __transmute::(1u32); + const U32_U64: u64 = __transmute::(1u32); assert(U32_U64 == 0x0000000000000001u64); - const U64_U32 = __transmute::(1u64); + const U64_U32: u32 = __transmute::(1u64); assert(U64_U32 == 0x00000001u32); } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/non_literal_const_decl/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/non_literal_const_decl/src/main.sw index aeb6304cc23..84168d5a6dd 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/non_literal_const_decl/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/non_literal_const_decl/src/main.sw @@ -1,6 +1,6 @@ script; -const GLOBAL_NUM = a_number(1, 2, 3); +const GLOBAL_NUM: u64 = a_number(1, 2, 3); fn a_number(_a: u64, _b: u64, _c: u64) -> u64 { 42 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_2.sw index 1fa9465b0ec..86b95b1ca0d 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { W: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_3.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_3.sw index cbc06d1bdc4..2f64fb4759f 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_3.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_3.sw @@ -14,7 +14,7 @@ pub enum Items3_Variants { V: u64, } -pub const ITEMS_3_FUNCTION_RES = 13278; +pub const ITEMS_3_FUNCTION_RES: u64 = 13278; pub fn items_3_function() -> u64 { ITEMS_3_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_4.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_4.sw index 809d49cc952..cf60d4d616a 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_4.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/aliases/src/items_4.sw @@ -14,7 +14,7 @@ pub enum Items4_Variants { T: u64, } -pub const ITEMS_4_FUNCTION_RES = 14278; +pub const ITEMS_4_FUNCTION_RES: u64 = 14278; pub fn items_4_function() -> u64 { ITEMS_4_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_2.sw index 1fa9465b0ec..86b95b1ca0d 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { W: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_3.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_3.sw index 40359c434ad..c2907ee3328 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_3.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_3.sw @@ -14,7 +14,7 @@ pub enum Items3_Variants { V: u64, } -pub const ITEMS_3_FUNCTION_RES = 1111; +pub const ITEMS_3_FUNCTION_RES: u64 = 1111; pub fn items_3_function() -> u64 { ITEMS_3_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_4.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_4.sw index 2d93dc802f4..c66c7aee263 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_4.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/multiple_imports_of_same_reexport/src/items_4.sw @@ -14,7 +14,7 @@ pub enum Items4_Variants { T: u64, } -pub const ITEMS_4_FUNCTION_RES = 5325; +pub const ITEMS_4_FUNCTION_RES: u64 = 5325; pub fn items_4_function() -> u64 { ITEMS_4_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_1_items/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_1_items/src/lib.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_1_items/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_1_items/src/lib.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_2_items/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_2_items/src/lib.sw index 3802e175e76..8b587fe4f35 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_2_items/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_2_items/src/lib.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { W: u64, } -pub const ITEMS_2_FUNCTION_RES = 324; +pub const ITEMS_2_FUNCTION_RES: u64 = 324; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_3_items/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_3_items/src/lib.sw index 4d61d81be80..37084bf8249 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_3_items/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_3_items/src/lib.sw @@ -14,7 +14,7 @@ pub enum Items3_Variants { V: u64, } -pub const ITEMS_3_FUNCTION_RES = 893; +pub const ITEMS_3_FUNCTION_RES: u64 = 893; pub fn items_3_function() -> u64 { ITEMS_3_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_4_items/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_4_items/src/lib.sw index 740942a391a..3d9c16f0e81 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_4_items/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_4_items/src/lib.sw @@ -14,7 +14,7 @@ pub enum Items4_Variants { T: u64, } -pub const ITEMS_4_FUNCTION_RES = 2389; +pub const ITEMS_4_FUNCTION_RES: u64 = 2389; pub fn items_4_function() -> u64 { ITEMS_4_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_5_items/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_5_items/src/lib.sw index b8bd79e4559..488101c3f81 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_5_items/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/reexport_paths_external_lib/ext_5_items/src/lib.sw @@ -14,7 +14,7 @@ pub enum Items5_Variants { R: u64, } -pub const ITEMS_5_FUNCTION_RES = 32894; +pub const ITEMS_5_FUNCTION_RES: u64 = 32894; pub fn items_5_function() -> u64 { ITEMS_5_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_1.sw index 95b236919b7..b55c8caa650 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_1.sw @@ -9,7 +9,7 @@ pub enum Items1_Enum { B: bool, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> bool { ITEMS_1_FUNCTION_RES == 456 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_2_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_2_1.sw index f00aa5f00c7..ff4f4241fcb 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_2_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_2_1.sw @@ -9,7 +9,7 @@ pub enum Items2_Enum { D: bool, } -pub const ITEMS_2_FUNCTION_RES = 789; +pub const ITEMS_2_FUNCTION_RES: u64 = 789; pub fn items_2_function() -> bool { ITEMS_2_FUNCTION_RES == 789 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_2_2.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_2_2.sw index 6822e86d865..4dfd9875229 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_2_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_2_2.sw @@ -9,7 +9,7 @@ pub enum Items2_Enum { D: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_3_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_3_1.sw index 86138d9e3ed..021cd0f64ee 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_3_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_3_1.sw @@ -14,7 +14,7 @@ pub enum Items3_Variants { H: bool, } -pub const ITEMS_3_FUNCTION_RES = 1234; +pub const ITEMS_3_FUNCTION_RES: u64 = 1234; pub fn items_3_function() -> bool { ITEMS_3_FUNCTION_RES == 1234 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_4_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_4_1.sw index 2d9be57fc13..40835091d78 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_4_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_4_1.sw @@ -14,7 +14,7 @@ pub enum Items4_Variants { L: bool, } -pub const ITEMS_4_FUNCTION_RES = 5678; +pub const ITEMS_4_FUNCTION_RES: u64 = 5678; pub fn items_4_function() -> bool { ITEMS_4_FUNCTION_RES == 5678 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_4_2.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_4_2.sw index d57d5b3fbc6..debb7bd3e34 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_4_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/items_4_2.sw @@ -14,7 +14,7 @@ pub enum Items4_Variants { L: u64, } -pub const ITEMS_4_FUNCTION_RES = 8765; +pub const ITEMS_4_FUNCTION_RES: u64 = 8765; pub fn items_4_function() -> u64 { ITEMS_4_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/lib_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/lib_1.sw index 642395e6bf1..a88612b6d52 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/lib_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/lib_1.sw @@ -11,7 +11,7 @@ pub enum Items1_Enum { B: u64, } -pub const ITEMS_1_FUNCTION_RES = 654; +pub const ITEMS_1_FUNCTION_RES: u64 = 654; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/lib_3.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/lib_3.sw index 04f9a81605f..a7d2ba3ccfc 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/lib_3.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/shadowing_in_reexporting_module/src/lib_3.sw @@ -17,7 +17,7 @@ pub enum Items3_Variants { H: u64, } -pub const ITEMS_3_FUNCTION_RES = 4321; +pub const ITEMS_3_FUNCTION_RES: u64 = 4321; pub fn items_3_function() -> u64 { ITEMS_3_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_glob_import/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_glob_import/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_glob_import/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_glob_import/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_glob_import/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_glob_import/src/items_2.sw index 654a63ac267..54346f66779 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_glob_import/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_glob_import/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { P: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_item_import/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_item_import/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_item_import/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_item_import/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_item_import/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_item_import/src/items_2.sw index 654a63ac267..54346f66779 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_item_import/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_item_import/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { P: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_path_access/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_path_access/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_path_access/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_path_access/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_path_access/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_path_access/src/items_2.sw index 250723123de..a85913da383 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_path_access/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/simple_path_access/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { P: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/visibility/src/items_1.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/visibility/src/items_1.sw index 45f1e280573..20fc4ff0e45 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/visibility/src/items_1.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/visibility/src/items_1.sw @@ -14,7 +14,7 @@ pub enum Items1_Variants { Y: u64, } -pub const ITEMS_1_FUNCTION_RES = 456; +pub const ITEMS_1_FUNCTION_RES: u64 = 456; pub fn items_1_function() -> u64 { ITEMS_1_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/visibility/src/items_2.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/visibility/src/items_2.sw index 1fa9465b0ec..86b95b1ca0d 100755 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/visibility/src/items_2.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/reexport/visibility/src/items_2.sw @@ -14,7 +14,7 @@ pub enum Items2_Variants { W: u64, } -pub const ITEMS_2_FUNCTION_RES = 987; +pub const ITEMS_2_FUNCTION_RES: u64 = 987; pub fn items_2_function() -> u64 { ITEMS_2_FUNCTION_RES diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/retd_b256/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/retd_b256/src/main.sw index a32c669f37c..269540d7396 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/retd_b256/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/retd_b256/src/main.sw @@ -1,7 +1,7 @@ script; // Use local constant to avoid importing `std`. -const ZERO_B256 = 0x0000000000000000000000000000000000000000000000000000000000000000; +const ZERO_B256: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000; // a b256 is bigger than a word, so RETD should be used instead of RET. fn main() -> b256 { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/smo_opcode/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/smo_opcode/src/main.sw index 335b2f9c954..98b470312c7 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/smo_opcode/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/smo_opcode/src/main.sw @@ -1,7 +1,7 @@ script; // Use local constant to avoid importing `std`. -const ZERO_B256 = 0x0000000000000000000000000000000000000000000000000000000000000000; +const ZERO_B256: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000; fn main() -> bool { asm(recipient: ZERO_B256, msg_len: 0, output: 0, coins: 0) { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/non_payable_implicit_zero_coins/src/wallet.sw b/test/src/e2e_vm_tests/test_programs/should_pass/non_payable_implicit_zero_coins/src/wallet.sw index 3e014cefab1..ea52430cef1 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/non_payable_implicit_zero_coins/src/wallet.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/non_payable_implicit_zero_coins/src/wallet.sw @@ -10,7 +10,7 @@ use std::{ }; use wallet_abi::Wallet; -const OWNER_ADDRESS = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); +const OWNER_ADDRESS: Address = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); storage { balance: u64 = 0, diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/non_payable_zero_coins_let_binding/src/wallet.sw b/test/src/e2e_vm_tests/test_programs/should_pass/non_payable_zero_coins_let_binding/src/wallet.sw index be8b485ea0c..c03e8610134 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/non_payable_zero_coins_let_binding/src/wallet.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/non_payable_zero_coins_let_binding/src/wallet.sw @@ -10,7 +10,7 @@ use std::{ }; use wallet_abi::Wallet; -const OWNER_ADDRESS = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); +const OWNER_ADDRESS: Address = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); storage { balance: u64 = 0, diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/payable_non_zero_coins/src/wallet.sw b/test/src/e2e_vm_tests/test_programs/should_pass/payable_non_zero_coins/src/wallet.sw index be8b485ea0c..c03e8610134 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/payable_non_zero_coins/src/wallet.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/payable_non_zero_coins/src/wallet.sw @@ -10,7 +10,7 @@ use std::{ }; use wallet_abi::Wallet; -const OWNER_ADDRESS = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); +const OWNER_ADDRESS: Address = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861); storage { balance: u64 = 0, diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw index 83ce6763fbd..7f982e24f0d 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw @@ -4,9 +4,9 @@ use array_of_structs_abi::{Id, TestContract, Wrapper}; use std::hash::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0x14ed3cd06c2947248f69d54bfa681fe40d26267be84df7e19e253622b7921bbe; +const CONTRACT_ID: b256 = 0x14ed3cd06c2947248f69d54bfa681fe40d26267be84df7e19e253622b7921bbe; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x878d6215fe8d406e08cb18053c97ee8bb25ba651e17e7cfe4964fc653b2f6808; // AUTO-CONTRACT-ID ../../test_contracts/array_of_structs_contract --release +const CONTRACT_ID: b256 = 0x878d6215fe8d406e08cb18053c97ee8bb25ba651e17e7cfe4964fc653b2f6808; // AUTO-CONTRACT-ID ../../test_contracts/array_of_structs_contract --release fn get_address() -> Option { Some(CONTRACT_ID.into()) diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw index baf9826e510..48c9580a3bb 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw @@ -7,14 +7,14 @@ use std::constants::DEFAULT_SUB_ID; use test_fuel_coin_abi::*; #[cfg(experimental_new_encoding = false)] -const FUEL_COIN_CONTRACT_ID = 0xec2277ebe007ade87e3d797c3b1e070dcd542d5ef8f038b471f262ef9cebc87c; +const FUEL_COIN_CONTRACT_ID: b256 = 0xec2277ebe007ade87e3d797c3b1e070dcd542d5ef8f038b471f262ef9cebc87c; #[cfg(experimental_new_encoding = true)] -const FUEL_COIN_CONTRACT_ID = 0x6e8bc09f34b7eccea8cf518a38754669515084377ec13d8fd73f83da519816ad; // AUTO-CONTRACT-ID ../../test_contracts/test_fuel_coin_contract --release +const FUEL_COIN_CONTRACT_ID: b256 = 0x6e8bc09f34b7eccea8cf518a38754669515084377ec13d8fd73f83da519816ad; // AUTO-CONTRACT-ID ../../test_contracts/test_fuel_coin_contract --release #[cfg(experimental_new_encoding = false)] -const BALANCE_CONTRACT_ID = 0xf6cd545152ac83225e8e7df2efb5c6fa6e37bc9b9e977b5ea8103d28668925df; +const BALANCE_CONTRACT_ID: b256 = 0xf6cd545152ac83225e8e7df2efb5c6fa6e37bc9b9e977b5ea8103d28668925df; #[cfg(experimental_new_encoding = true)] -const BALANCE_CONTRACT_ID = 0xe78343b4ba20a65a3d012ab5f33366c0138672c71032d0c17f3f0485bd820477; // AUTO-CONTRACT-ID ../../test_contracts/balance_test_contract --release +const BALANCE_CONTRACT_ID: b256 = 0xe78343b4ba20a65a3d012ab5f33366c0138672c71032d0c17f3f0485bd820477; // AUTO-CONTRACT-ID ../../test_contracts/balance_test_contract --release fn main() -> bool { let default_gas = 1_000_000_000_000; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw index 1a12e43061d..b9131e4e19e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw @@ -3,9 +3,9 @@ script; use balance_test_abi::BalanceTest; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xf6cd545152ac83225e8e7df2efb5c6fa6e37bc9b9e977b5ea8103d28668925df; +const CONTRACT_ID: b256 = 0xf6cd545152ac83225e8e7df2efb5c6fa6e37bc9b9e977b5ea8103d28668925df; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xe78343b4ba20a65a3d012ab5f33366c0138672c71032d0c17f3f0485bd820477; // AUTO-CONTRACT-ID ../../test_contracts/balance_test_contract --release +const CONTRACT_ID: b256 = 0xe78343b4ba20a65a3d012ab5f33366c0138672c71032d0c17f3f0485bd820477; // AUTO-CONTRACT-ID ../../test_contracts/balance_test_contract --release fn main() -> bool { let balance_test_contract = abi(BalanceTest, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw index 1562bf19993..adfb1ae5077 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw @@ -4,9 +4,9 @@ use abi_with_tuples::{MyContract, Location, Person}; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xfdc14550c8aee742cd556d0ab7f378b7be0d3b1e6e086c097352e94590d4ed02; +const CONTRACT_ID: b256 = 0xfdc14550c8aee742cd556d0ab7f378b7be0d3b1e6e086c097352e94590d4ed02; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xe77828cc9433f3714af73bad1198b5234542eedc1e616d5c26c1643f216ebdd4; // AUTO-CONTRACT-ID ../../test_contracts/abi_with_tuples_contract --release +const CONTRACT_ID: b256 = 0xe77828cc9433f3714af73bad1198b5234542eedc1e616d5c26c1643f216ebdd4; // AUTO-CONTRACT-ID ../../test_contracts/abi_with_tuples_contract --release fn main() -> bool { let the_abi = abi(MyContract, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw index e3c6ff4d00c..ff6aff8ccbc 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw @@ -2,9 +2,9 @@ script; use basic_storage_abi::{BasicStorage, Quad}; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0x94db39f409a31b9f2ebcadeea44378e419208c20de90f5d8e1e33dc1523754cb; +const CONTRACT_ID: b256 = 0x94db39f409a31b9f2ebcadeea44378e419208c20de90f5d8e1e33dc1523754cb; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xdda92a285d294c47fdd59cb82fedc380ed7337cbbd93593cf9dc943a2ca74072; // AUTO-CONTRACT-ID ../../test_contracts/basic_storage --release +const CONTRACT_ID: b256 = 0xdda92a285d294c47fdd59cb82fedc380ed7337cbbd93593cf9dc943a2ca74072; // AUTO-CONTRACT-ID ../../test_contracts/basic_storage --release fn main() -> u64 { let addr = abi(BasicStorage, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw index 9c3f916f838..0539799c7c5 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw @@ -3,9 +3,9 @@ script; use contract_with_type_aliases_abi::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0x0cbeb6efe3104b460be769bdc4ea101ebf16ccc16f2d7b667ec3e1c7f5ce35b5; +const CONTRACT_ID: b256 = 0x0cbeb6efe3104b460be769bdc4ea101ebf16ccc16f2d7b667ec3e1c7f5ce35b5; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xb0899ebf2030d48330436b8025b9ca15243ac985f54024ea00d64d961b67482a; // AUTO-CONTRACT-ID ../../test_contracts/contract_with_type_aliases --release +const CONTRACT_ID: b256 = 0xb0899ebf2030d48330436b8025b9ca15243ac985f54024ea00d64d961b67482a; // AUTO-CONTRACT-ID ../../test_contracts/contract_with_type_aliases --release fn main() { let caller = abi(MyContract, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw index ab95a504a90..8970daef1e4 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw @@ -4,9 +4,9 @@ use increment_abi::Incrementor; use dynamic_contract_call::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xd1b4047af7ef111c023ab71069e01dc2abfde487c0a0ce1268e4f447e6c6e4c2; +const CONTRACT_ID: b256 = 0xd1b4047af7ef111c023ab71069e01dc2abfde487c0a0ce1268e4f447e6c6e4c2; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x0d25f1daa7976a7540b0e3d8ccdd30c3465693a3cf5bd55fe4aedf456aafe85b; // AUTO-CONTRACT-ID ../../test_contracts/increment_contract --release +const CONTRACT_ID: b256 = 0x0d25f1daa7976a7540b0e3d8ccdd30c3465693a3cf5bd55fe4aedf456aafe85b; // AUTO-CONTRACT-ID ../../test_contracts/increment_contract --release fn main() -> bool { let the_abi = abi(Incrementor, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw index e9cfbe6075c..7e4048b2665 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw @@ -3,9 +3,9 @@ script; use storage_enum_abi::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xc601d11767195485a6654d566c67774134668863d8c797a8c69e8778fb1f89e9; +const CONTRACT_ID: b256 = 0xc601d11767195485a6654d566c67774134668863d8c797a8c69e8778fb1f89e9; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x9ff1242ab03642c1977b8a1d3b6fe8dd0fd2780cf039ed75e6f1503cefece8f8; // AUTO-CONTRACT-ID ../../test_contracts/storage_enum_contract --release +const CONTRACT_ID: b256 = 0x9ff1242ab03642c1977b8a1d3b6fe8dd0fd2780cf039ed75e6f1503cefece8f8; // AUTO-CONTRACT-ID ../../test_contracts/storage_enum_contract --release fn main() -> u64 { let caller = abi(StorageEnum, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw index a4978f0c62d..be428db781d 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw @@ -3,9 +3,9 @@ script; use auth_testing_abi::AuthTesting; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xc2eec20491b53aab7232cbd27c31d15417b4e9daf0b89c74cc242ef1295f681f; +const CONTRACT_ID: b256 = 0xc2eec20491b53aab7232cbd27c31d15417b4e9daf0b89c74cc242ef1295f681f; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x6ab2528386b7d41c88a6dabe8a05b2f7b392984d4ec9b90be9e71a4f8815e1a8; // AUTO-CONTRACT-ID ../../test_contracts/auth_testing_contract --release +const CONTRACT_ID: b256 = 0x6ab2528386b7d41c88a6dabe8a05b2f7b392984d4ec9b90be9e71a4f8815e1a8; // AUTO-CONTRACT-ID ../../test_contracts/auth_testing_contract --release // should be false in the case of a script fn main() -> bool { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw index d3916a9666c..882601fbd7a 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw @@ -4,9 +4,9 @@ use std::codec::*; use context_testing_abi::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0x6054c11cda000f5990373a4d61929396165be4dfdd61d5b7bd26da60ab0d8577; +const CONTRACT_ID: b256 = 0x6054c11cda000f5990373a4d61929396165be4dfdd61d5b7bd26da60ab0d8577; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x6dc84334725f3455666302c8570a2c5a48b17c1057f3a7b1e1b8e3845ab7e6bd; // AUTO-CONTRACT-ID ../../test_contracts/context_testing_contract --release +const CONTRACT_ID: b256 = 0x6dc84334725f3455666302c8570a2c5a48b17c1057f3a7b1e1b8e3845ab7e6bd; // AUTO-CONTRACT-ID ../../test_contracts/context_testing_contract --release fn main() -> bool { let gas: u64 = u64::max(); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw index 7548740ac18..fdf44d87b5f 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw @@ -3,9 +3,9 @@ script; use nested_struct_args_abi::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xe63d33a1b3a6903808b379f6a41a72fa8a370e8b76626775e7d9d2f9c4c5da40; +const CONTRACT_ID: b256 = 0xe63d33a1b3a6903808b379f6a41a72fa8a370e8b76626775e7d9d2f9c4c5da40; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x808902b1d27b2c477f3c0821e033fb7bf256060a47deb57e84881afde7ed933f; // AUTO-CONTRACT-ID ../../test_contracts/nested_struct_args_contract --release +const CONTRACT_ID: b256 = 0x808902b1d27b2c477f3c0821e033fb7bf256060a47deb57e84881afde7ed933f; // AUTO-CONTRACT-ID ../../test_contracts/nested_struct_args_contract --release fn main() -> bool { let caller = abi(NestedStructArgs, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw index 95badb579e2..b65789fcab7 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw @@ -4,9 +4,9 @@ use storage_access_abi::*; use std::hash::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0x3bc28acd66d327b8c1b9624c1fabfc07e9ffa1b5d71c2832c3bfaaf8f4b805e9; +const CONTRACT_ID: b256 = 0x3bc28acd66d327b8c1b9624c1fabfc07e9ffa1b5d71c2832c3bfaaf8f4b805e9; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x72c284ba7b906df994e63faf09382bfbf01aa7de8a9452665b66cdf0e3eb1978; // AUTO-CONTRACT-ID ../../test_contracts/storage_access_contract --release +const CONTRACT_ID: b256 = 0x72c284ba7b906df994e63faf09382bfbf01aa7de8a9452665b66cdf0e3eb1978; // AUTO-CONTRACT-ID ../../test_contracts/storage_access_contract --release fn main() -> bool { let caller = abi(StorageAccess, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block/src/main.sw index 22112bac422..68253dcf90e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block/src/main.sw @@ -1,6 +1,6 @@ contract; -const KEY = 0x0000000000000000000000000000000000000000000000000000000000000000; +const KEY: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000; abi TestAbi { #[storage(write)] diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_mint_burn/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_mint_burn/src/main.sw index 225347cbcfe..a61ddd21355 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_mint_burn/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_mint_burn/src/main.sw @@ -5,8 +5,8 @@ abi TestAbi { fn burn(); } -const AMOUNT_TO_BURN = 100; -const ASSET_ID = b256::zero(); +const AMOUNT_TO_BURN: u64 = 100; +const ASSET_ID: b256 = b256::zero(); impl TestAbi for Contract { fn mint() { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_read/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_read/src/main.sw index e7a58fd45ca..9524eaa5816 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_read/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/static_analysis/cei_pattern_violation_in_asm_block_read/src/main.sw @@ -1,6 +1,6 @@ contract; -const KEY = 0x0000000000000000000000000000000000000000000000000000000000000000; +const KEY: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000; abi TestAbi { #[storage(read)] diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/require/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/require/src/main.sw index c640a726e34..40bfa2fb16e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/require/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/stdlib/require/src/main.sw @@ -1,7 +1,7 @@ script; -const MY_CUSTOM_ERROR_MESSAGE = 100; -const forty_twos = 0x4242424242424242424242424242424242424242424242424242424242424242; +const MY_CUSTOM_ERROR_MESSAGE: u64 = 100; +const forty_twos: b256 = 0x4242424242424242424242424242424242424242424242424242424242424242; struct CustomError { val_1: bool, diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/src/main.sw index 251577caf5b..9e24cf3c390 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/basic_storage/src/main.sw @@ -2,9 +2,9 @@ contract; use std::{hash::*, storage::storage_api::{read, write}}; use basic_storage_abi::*; -const C1 = 1; -const NS1_NS2_C1 = 2; -const S5 = __to_str_array("aaaaa"); +const C1: u8 = 1; +const NS1_NS2_C1: u64 = 2; +const S5: str[5] = __to_str_array("aaaaa"); const C1KEY: b256 = 0x933a534d4af4c376b0b569e8d8a2c62e635e26f403e124cb91d9c42e83d54373; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/src/main.sw index d84c9d9ee3b..5cedeeb0d06 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/storage_namespace/src/main.sw @@ -2,8 +2,8 @@ contract; use std::{hash::*, storage::storage_api::{read, write}}; use basic_storage_abi::*; -const C1 = 1; -const S5 = __to_str_array("aaaaa"); +const C1: u64 = 1; +const S5: str[5] = __to_str_array("aaaaa"); storage { my_storage_namespace { diff --git a/test/src/ir_generation/tests/gtf.sw b/test/src/ir_generation/tests/gtf.sw index 7736f2dd9b6..2a2e5e49069 100644 --- a/test/src/ir_generation/tests/gtf.sw +++ b/test/src/ir_generation/tests/gtf.sw @@ -2,8 +2,8 @@ script; -const SOME_TX_FIELD = 0x42; -const SOME_OTHER_TX_FIELD = 0x77; +const SOME_TX_FIELD: u64 = 0x42; +const SOME_OTHER_TX_FIELD: u64 = 0x77; fn main() -> (u64, b256) { let field1 = __gtf::(1, SOME_TX_FIELD); diff --git a/test/src/ir_generation/tests/local_const_init.sw b/test/src/ir_generation/tests/local_const_init.sw index 727f2c693d1..8b7d05e5e9c 100644 --- a/test/src/ir_generation/tests/local_const_init.sw +++ b/test/src/ir_generation/tests/local_const_init.sw @@ -10,15 +10,15 @@ fn s(x : u64) -> S { fn main() -> u64 { // unsigned integers - const A = !0u8; - const B = !0u16; - const C = !0u32; - const D = !0u64; + const A: u8 = !0u8; + const B: u16 = !0u16; + const C: u32 = !0u32; + const D: u64 = !0u64; // bool - const E = !true; + const E: bool = !true; - const X = s(1); + const X: S = s(1); X.s } diff --git a/test/src/ir_generation/tests/storage_metadata.sw b/test/src/ir_generation/tests/storage_metadata.sw index 0b3345f1265..c82d2eda4e8 100644 --- a/test/src/ir_generation/tests/storage_metadata.sw +++ b/test/src/ir_generation/tests/storage_metadata.sw @@ -1,6 +1,6 @@ contract; -const KEY = 0x0000000000000000000000000000000000000000000000000000000000000000; +const KEY: b256 = 0x0000000000000000000000000000000000000000000000000000000000000000; abi Incrementor { #[storage(write)] @@ -50,13 +50,13 @@ impl Incrementor for Contract { // check: fn initialize<557ac400>(initial_value $MD: u64) -> u64, $(init_md=$MD) { // unordered: $(write_md=$MD) = purity "writes" -// unordered: $(write_fn_name_md=$MD) = fn_name_span $MD 359 369 +// unordered: $(write_fn_name_md=$MD) = fn_name_span $MD 365 375 // unordered: $(readwrite_md=$MD) = purity "readswrites" -// unordered: $(readwrite_fn_name_md=$MD) = fn_name_span $MD 553 562 +// unordered: $(readwrite_fn_name_md=$MD) = fn_name_span $MD 559 568 // unordered: $(read_md=$MD) = purity "reads" -// unordered: $(read_fn_name_md=$MD) = fn_name_span $MD 833 836 +// unordered: $(read_fn_name_md=$MD) = fn_name_span $MD 839 842 // The span idx is first, then the storage attribute, then the function name attribute.