-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow same named types and functions (#839)
### What Change the names of the static variables that contain the spec XDR to include a type or function qualifier for the kind of entry the spec contains. ### Why To allow same named types and functions in contracts. When a type and function have the same name today they result in two static variables that have the same names. Adding a qualifier to what they are to those variables names will stop them from colliding. Close #828
- Loading branch information
1 parent
84d8162
commit db018aa
Showing
11 changed files
with
37 additions
and
9 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
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
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
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
27 changes: 27 additions & 0 deletions
27
soroban-sdk/src/tests/contract_overlapping_type_fn_names.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,27 @@ | ||
use crate as soroban_sdk; | ||
use soroban_sdk::{contractimpl, contracttype, Env}; | ||
|
||
#[derive(Copy, Clone, Debug, Eq, PartialEq)] | ||
#[contracttype] | ||
pub struct State { | ||
pub a: i32, | ||
} | ||
|
||
pub struct Contract; | ||
|
||
#[contractimpl] | ||
impl Contract { | ||
pub fn state() -> State { | ||
State { a: 1 } | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_functional() { | ||
let env = Env::default(); | ||
let contract_id = env.register_contract(None, Contract); | ||
|
||
let client = ContractClient::new(&env, &contract_id); | ||
let s = client.state(); | ||
assert_eq!(s, State { a: 1 }); | ||
} |
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