diff --git a/dust-lang/src/abstract_tree/map_index.rs b/dust-lang/src/abstract_tree/map_index.rs
index ba31f5a..21ff265 100644
--- a/dust-lang/src/abstract_tree/map_index.rs
+++ b/dust-lang/src/abstract_tree/map_index.rs
@@ -69,6 +69,24 @@ impl AbstractNode for MapIndex {
};
}
+ if let (
+ Expression::Value(ValueNode::Structure { fields, .. }),
+ Expression::Identifier(identifier),
+ ) = (&self.left.node, &self.right.node)
+ {
+ return if let Some(type_result) = fields.iter().find_map(|(property, expression)| {
+ if property == identifier {
+ Some(expression.node.expected_type(context))
+ } else {
+ None
+ }
+ }) {
+ type_result
+ } else {
+ Ok(Type::None)
+ };
+ }
+
Err(ValidationError::CannotIndexWith {
collection_type: self.left.node.expected_type(context)?,
collection_position: self.left.position,
diff --git a/dust-lang/src/lib.rs b/dust-lang/src/lib.rs
index 08e1e3c..aafd428 100644
--- a/dust-lang/src/lib.rs
+++ b/dust-lang/src/lib.rs
@@ -6,7 +6,11 @@ pub mod lexer;
pub mod parser;
pub mod value;
-use std::{cell::RefCell, ops::Range, rc::Rc, vec};
+use std::{
+ ops::Range,
+ sync::{Arc, RwLock},
+ vec,
+};
use abstract_tree::Type;
use ariadne::{Color, Fmt, Label, Report, ReportKind};
@@ -14,42 +18,48 @@ use context::Context;
use error::{Error, RuntimeError, TypeConflict, ValidationError};
use lexer::lex;
use parser::parse;
+use rayon::prelude::*;
pub use value::Value;
pub fn interpret<'src>(source_id: &str, source: &str) -> Result