Skip to content

Commit f6fff25

Browse files
authored
Merge pull request #5059 from stacks-network/clarity-wasm-develop-typemap-patch
add methods to TypeMap
2 parents cbcc7bb + 16919da commit f6fff25

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

clarity/src/vm/analysis/type_checker/contexts.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ impl TypeMap {
8686
}
8787
}
8888

89+
/// Like set_type but forcing a change if already set
90+
pub fn overwrite_type(&mut self, expr: &SymbolicExpression, type_sig: TypeSignature) {
91+
if let TypeMapDataType::Map(ref mut map) = self.map {
92+
map.insert(expr.id, type_sig);
93+
}
94+
}
95+
96+
pub fn get_type(&self, expr: &SymbolicExpression) -> Option<&TypeSignature> {
97+
match self.map {
98+
TypeMapDataType::Map(ref map) => map.get(&expr.id),
99+
_ => None,
100+
}
101+
}
102+
89103
pub fn get_type_expected(&self, expr: &SymbolicExpression) -> Option<&TypeSignature> {
90104
match self.map {
91105
TypeMapDataType::Map(ref map) => map.get(&expr.id),

0 commit comments

Comments
 (0)