Improve context recursion
This commit is contained in:
parent
dce6dfbc40
commit
0e52ed7a49
@ -58,7 +58,6 @@ pub use self::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
context::Context,
|
context::Context,
|
||||||
error::{DustError, RuntimeError, ValidationError},
|
error::{DustError, RuntimeError, ValidationError},
|
||||||
identifier::Identifier,
|
|
||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -219,10 +219,15 @@ impl Context {
|
|||||||
pub fn set_type(&self, identifier: Identifier, r#type: Type) -> Result<(), PoisonError> {
|
pub fn set_type(&self, identifier: Identifier, r#type: Type) -> Result<(), PoisonError> {
|
||||||
log::debug!("Setting {identifier} to type {}", r#type);
|
log::debug!("Setting {identifier} to type {}", r#type);
|
||||||
|
|
||||||
self.data
|
let mut data = self.data.write()?;
|
||||||
.write()?
|
let usage_data = data
|
||||||
.variables
|
.variables
|
||||||
.insert(identifier, (VariableData::Type(r#type), UsageData::new()));
|
.remove(&identifier)
|
||||||
|
.map(|(_, usage_data)| usage_data)
|
||||||
|
.unwrap_or_else(|| UsageData::new());
|
||||||
|
|
||||||
|
data.variables
|
||||||
|
.insert(identifier, (VariableData::Type(r#type), usage_data));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user