forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add const probing to delineated path type check (FuelLabs#3080)
closes FuelLabs#3063.
- Loading branch information
1 parent
99df7b1
commit daa3ecc
Showing
10 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
sway-core/src/semantic_analysis/ast_node/expression/typed_expression/constant_decleration.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use sway_types::{Span, Spanned}; | ||
|
||
use crate::{ | ||
error::*, | ||
language::ty::{self, TyConstantDeclaration}, | ||
CompileResult, | ||
}; | ||
|
||
pub(crate) fn instantiate_constant_decl( | ||
const_decl: TyConstantDeclaration, | ||
span: Span, | ||
) -> CompileResult<ty::TyExpression> { | ||
ok( | ||
ty::TyExpression { | ||
expression: ty::TyExpressionVariant::VariableExpression { | ||
name: const_decl.name.clone(), | ||
span: const_decl.name.span(), | ||
mutability: ty::VariableMutability::Immutable, | ||
}, | ||
return_type: const_decl.value.return_type, | ||
span, | ||
}, | ||
vec![], | ||
vec![], | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_with_call_path/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[[package]] | ||
name = 'const_decl_with_call_path' | ||
source = 'root' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-8403A6B918C3B0C1' | ||
dependencies = [] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-8403A6B918C3B0C1' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_with_call_path/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "const_decl_with_call_path" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |
22 changes: 22 additions & 0 deletions
22
...m_tests/test_programs/should_pass/language/const_decl_with_call_path/json_abi_oracle.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"functions": [ | ||
{ | ||
"inputs": [], | ||
"name": "main", | ||
"output": { | ||
"name": "", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
} | ||
], | ||
"loggedTypes": [], | ||
"types": [ | ||
{ | ||
"components": null, | ||
"type": "u64", | ||
"typeId": 0, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
...src/e2e_vm_tests/test_programs/should_pass/language/const_decl_with_call_path/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
script; | ||
|
||
dep test_lib; | ||
|
||
use std::{assert::assert, contract_id::ContractId}; | ||
|
||
fn main() -> u64 { | ||
let x = test_lib::NUMBER; | ||
let zero = std::constants::ZERO_B256; | ||
let base_asset_id = std::constants::BASE_ASSET_ID; | ||
assert(zero == 0x0000000000000000000000000000000000000000000000000000000000000000); | ||
assert(base_asset_id == ~ContractId::from(zero)); | ||
x | ||
} |
3 changes: 3 additions & 0 deletions
3
...e2e_vm_tests/test_programs/should_pass/language/const_decl_with_call_path/src/test_lib.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
library test_lib; | ||
|
||
pub const NUMBER: u64 = 10; |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_pass/language/const_decl_with_call_path/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
category = "run" | ||
expected_result = { action = "return", value = 10 } | ||
validate_abi = true |