pub fn index(value: Type, index: Type) -> Result<Type, SemanticError> {
    match value {
        Type::Array(array) => index_array(array, index),
        Type::Map(map) => index_map(map, index),
        Type::Base(_) => Err(SemanticError::not_subscriptable()),
        Type::Tuple(_) => Err(SemanticError::not_subscriptable()),
        Type::String(_) => Err(SemanticError::not_subscriptable()),
        Type::Contract(_) => Err(SemanticError::not_subscriptable()),
        Type::Struct(_) => Err(SemanticError::not_subscriptable()),
    }
}
/// Finds the type of an indexed expression.
///
/// e.g. `foo[42]`
Finds the type of an indexed expression.
Finds the type of an indexed expression .
pub fn index(value: Type, index: Type) -> Result<Type, SemanticError> {
    match value {
        Type::Array(array) => index_array(array, index),
        Type::Map(map) => index_map(map, index),
        Type::Base(_) => Err(SemanticError::not_subscriptable()),
        Type::Tuple(_) => Err(SemanticError::not_subscriptable()),
        Type::String(_) => Err(SemanticError::not_subscriptable()),
        Type::Contract(_) => Err(SemanticError::not_subscriptable()),
        Type::Struct(_) => Err(SemanticError::not_subscriptable()),
    }
}
pub fn index ( value : Type , index : Type ) -> Result < Type , SemanticError > { match value { Type :: Array ( array ) => index_array ( array , index ) , Type :: Map ( map ) => index_map ( map , index ) , Type :: Base ( _ ) => Err ( SemanticError :: not_subscriptable ( ) ) , Type :: Tuple ( _ ) => Err ( SemanticError :: not_subscriptable ( ) ) , Type :: String ( _ ) => Err ( SemanticError :: not_subscriptable ( ) ) , Type :: Contract ( _ ) => Err ( SemanticError :: not_subscriptable ( ) ) , Type :: Struct ( _ ) => Err ( SemanticError :: not_subscriptable ( ) ) , } }
Finds the type of an indexed expression.
Finds the type of an indexed expression .
value
Type
index
Type
value
Type
index
Type