Change expect("exists") to unwrap().

This commit is contained in:
Stephen Chung 2022-01-06 11:07:52 +08:00
parent b1b4361d08
commit bc6bf6c6ba
15 changed files with 99 additions and 110 deletions

View File

@ -97,8 +97,7 @@ impl Engine {
resolver: &StaticModuleResolver,
imports: &mut BTreeSet<crate::Identifier>,
) {
ast.walk(
&mut |path| match path.last().expect("contains current node") {
ast.walk(&mut |path| match path.last().unwrap() {
// Collect all `import` statements with a string constant path
ASTNode::Stmt(Stmt::Import(Expr::StringConstant(s, _), _, _))
if !resolver.contains_path(s) && !imports.contains(s.as_str()) =>
@ -107,8 +106,7 @@ impl Engine {
true
}
_ => true,
},
);
});
}
let mut ast = self.compile_scripts_with_scope(scope, &[script])?;

View File

@ -4,7 +4,6 @@ use crate::func::{FnCallArgs, RegisterNativeFunction, SendSync};
use crate::types::dynamic::Variant;
use crate::{
Engine, FnAccess, FnNamespace, Identifier, Module, NativeCallContext, RhaiResultOf, Shared,
SmartString,
};
use std::any::{type_name, TypeId};
#[cfg(feature = "no_std")]
@ -15,13 +14,14 @@ impl Engine {
#[inline(always)]
#[allow(dead_code)]
pub(crate) fn global_namespace(&self) -> &Module {
self.global_modules.first().expect("not empty")
self.global_modules.first().unwrap()
}
/// Get a mutable reference to the global namespace module
/// (which is the first module in `global_modules`).
#[inline(always)]
pub(crate) fn global_namespace_mut(&mut self) -> &mut Module {
Shared::get_mut(self.global_modules.first_mut().expect("not empty")).expect("not shared")
let module = self.global_modules.first_mut().unwrap();
Shared::get_mut(module).expect("not shared")
}
/// Register a custom function with the [`Engine`].
///
@ -69,18 +69,20 @@ impl Engine {
}
#[cfg(feature = "metadata")]
let param_type_names: Option<crate::StaticVec<_>> =
Some(param_type_names.iter().map(|ty| ty.as_str()).collect());
let param_type_names: crate::StaticVec<_> =
param_type_names.iter().map(|ty| ty.as_str()).collect();
#[cfg(feature = "metadata")]
let param_type_names = Some(param_type_names.as_ref());
#[cfg(not(feature = "metadata"))]
let param_type_names: Option<[&str; 0]> = None;
let param_type_names: Option<&[&str]> = None;
self.global_namespace_mut().set_fn(
name,
FnNamespace::Global,
FnAccess::Public,
param_type_names.as_ref().map(<_>::as_ref),
&param_types,
param_type_names,
param_types,
func.into_callable_function(),
);
self
@ -127,18 +129,20 @@ impl Engine {
.collect();
#[cfg(feature = "metadata")]
let param_type_names: Option<crate::StaticVec<_>> =
Some(param_type_names.iter().map(|ty| ty.as_str()).collect());
let param_type_names: crate::StaticVec<_> =
param_type_names.iter().map(|ty| ty.as_str()).collect();
#[cfg(feature = "metadata")]
let param_type_names = Some(param_type_names.as_ref());
#[cfg(not(feature = "metadata"))]
let param_type_names: Option<[&str; 0]> = None;
let param_type_names: Option<&[&str]> = None;
self.global_namespace_mut().set_fn(
name,
FnNamespace::Global,
FnAccess::Public,
param_type_names.as_ref().map(<_>::as_ref),
&param_types,
param_type_names,
param_types,
func.into_callable_function(),
);
self
@ -280,8 +284,8 @@ impl Engine {
#[inline(always)]
pub fn register_type_with_name_raw(
&mut self,
fully_qualified_type_path: impl Into<SmartString>,
name: impl Into<SmartString>,
fully_qualified_type_path: impl Into<Identifier>,
name: impl Into<Identifier>,
) -> &mut Self {
// Add the pretty-print type name into the map
self.type_names

View File

@ -509,18 +509,15 @@ impl Expr {
#[cfg(not(feature = "no_index"))]
Self::Array(x, _) if self.is_constant() => {
let mut arr = crate::Array::with_capacity(x.len());
arr.extend(
x.iter()
.map(|v| v.get_literal_value().expect("constant value")),
);
arr.extend(x.iter().map(|v| v.get_literal_value().unwrap()));
Dynamic::from_array(arr)
}
#[cfg(not(feature = "no_object"))]
Self::Map(x, _) if self.is_constant() => {
Dynamic::from_map(x.0.iter().fold(x.1.clone(), |mut map, (k, v)| {
let value_ref = map.get_mut(k.name.as_str()).expect("contains all keys");
*value_ref = v.get_literal_value().expect("constant value");
let value_ref = map.get_mut(k.name.as_str()).unwrap();
*value_ref = v.get_literal_value().unwrap();
map
}))
}
@ -827,7 +824,7 @@ impl Expr {
_ => (),
}
path.pop().expect("contains current node");
path.pop().unwrap();
true
}

View File

@ -660,7 +660,7 @@ impl Stmt {
_ => (),
}
path.pop().expect("contains current node");
path.pop().unwrap();
true
}

View File

@ -849,7 +849,7 @@ impl EvalState {
// Push a new function resolution cache if the stack is empty
self.push_fn_resolution_cache();
}
self.fn_resolution_caches.last_mut().expect("not empty")
self.fn_resolution_caches.last_mut().unwrap()
}
/// Push an empty function resolution cache onto the stack and make it current.
#[allow(dead_code)]
@ -1200,11 +1200,11 @@ impl Engine {
if let Some(index) = index {
let offset = global.num_imported_modules() - index.get();
Some(global.get_shared_module(offset).expect("within range"))
Some(global.get_shared_module(offset).unwrap())
} else {
global
.find_module(root)
.map(|n| global.get_shared_module(n).expect("valid index"))
.map(|n| global.get_shared_module(n).unwrap())
.or_else(|| self.global_sub_modules.get(root).cloned())
}
}
@ -1335,7 +1335,7 @@ impl Engine {
level: 0,
};
match resolve_var(
expr.get_variable_name(true).expect("`Variable`"),
expr.get_variable_name(true).expect("`Expr::Variable`"),
index,
&context,
) {
@ -1352,7 +1352,7 @@ impl Engine {
scope.len() - index
} else {
// Find the variable in the scope
let var_name = expr.get_variable_name(true).expect("`Variable`");
let var_name = expr.get_variable_name(true).expect("`Expr::Variable`");
scope
.get_index(var_name)
.ok_or_else(|| ERR::ErrorVariableNotFound(var_name.to_string(), var_pos))?
@ -1386,7 +1386,7 @@ impl Engine {
let _terminate_chaining = terminate_chaining;
// Pop the last index value
let idx_val = idx_values.pop().expect("not empty");
let idx_val = idx_values.pop().unwrap();
match chain_type {
#[cfg(not(feature = "no_index"))]
@ -2389,13 +2389,16 @@ impl Engine {
let mut map = Dynamic::from_map(x.1.clone());
for (Ident { name, .. }, value_expr) in x.0.iter() {
*map.write_lock::<crate::Map>()
.expect("`Map`")
.get_mut(name.as_str())
.expect("exists") = self
let key = name.as_str();
let value = self
.eval_expr(scope, global, state, lib, this_ptr, value_expr, level)?
.flatten();
*map.write_lock::<crate::Map>()
.expect("`Map`")
.get_mut(key)
.unwrap() = value;
self.check_data_size(&map, value_expr.position())?;
}
@ -2446,8 +2449,8 @@ impl Engine {
Expr::Custom(custom, _) => {
let expressions: StaticVec<_> = custom.inputs.iter().map(Into::into).collect();
let key_token = custom.tokens.first().expect("not empty");
let custom_def = self.custom_syntax.get(key_token).expect("must match");
let key_token = custom.tokens.first().unwrap();
let custom_def = self.custom_syntax.get(key_token).unwrap();
let mut context = EvalContext {
engine: self,
scope,
@ -2808,7 +2811,7 @@ impl Engine {
let (mut lhs_ptr, pos) =
self.search_namespace(scope, global, state, lib, this_ptr, lhs_expr)?;
let var_name = lhs_expr.get_variable_name(false).expect("`Variable`");
let var_name = lhs_expr.get_variable_name(false).expect("`Expr::Variable`");
if !lhs_ptr.is_ref() {
return Err(ERR::ErrorAssignmentToConstant(var_name.to_string(), pos).into());
@ -3212,11 +3215,11 @@ impl Engine {
if err_pos.is_none() {
// No position info
} else {
let line = err_pos.line().expect("line number") as INT;
let line = err_pos.line().unwrap() as INT;
let position = if err_pos.is_beginning_of_line() {
0
} else {
err_pos.position().expect("character position")
err_pos.position().unwrap()
} as INT;
err_map.insert("line".into(), line.into());
err_map.insert("position".into(), position.into());

View File

@ -274,8 +274,7 @@ impl Engine {
}
})
} else {
let (first_arg, rest_args) =
args.split_first().expect("two arguments");
let (first_arg, rest_args) = args.split_first().unwrap();
get_builtin_op_assignment_fn(fn_name, *first_arg, rest_args[0])
.map(|f| FnResolutionCacheEntry {
@ -624,7 +623,7 @@ impl Engine {
let result = if _is_method_call {
// Method call of script function - map first argument to `this`
let (first_arg, rest_args) = args.split_first_mut().expect("not empty");
let (first_arg, rest_args) = args.split_first_mut().unwrap();
let level = _level + 1;
@ -1114,7 +1113,7 @@ impl Engine {
// avoid cloning the value
if curry.is_empty() && !a_expr.is_empty() && a_expr[0].is_variable_access(false) {
// func(x, ...) -> x.func(...)
let (first_expr, rest_expr) = a_expr.split_first().expect("not empty");
let (first_expr, rest_expr) = a_expr.split_first().unwrap();
rest_expr.iter().try_for_each(|expr| {
self.get_arg_value(scope, global, state, lib, this_ptr, level, expr, constants)
@ -1215,7 +1214,7 @@ impl Engine {
args.extend(arg_values.iter_mut());
} else {
// Turn it into a method call only if the object is not shared and not a simple value
let (first, rest) = arg_values.split_first_mut().expect("not empty");
let (first, rest) = arg_values.split_first_mut().unwrap();
first_arg_value = Some(first);
let obj_ref = target.take_ref().expect("ref");
args.push(obj_ref);

View File

@ -649,7 +649,7 @@ impl Module {
if let Some(f) = self.functions.get_mut(&hash_fn) {
let (param_names, return_type_name) = if param_names.len() > f.params {
let return_type = param_names.pop().expect("exists");
let return_type = param_names.pop().unwrap();
(param_names, return_type)
} else {
(param_names, Default::default())
@ -697,7 +697,7 @@ impl Module {
let comments = comments.as_ref();
if !comments.is_empty() {
let f = self.functions.get_mut(&hash_fn).expect("exists");
let f = self.functions.get_mut(&hash_fn).unwrap();
f.comments = Some(comments.iter().map(|s| s.as_ref().into()).collect());
}
@ -782,7 +782,7 @@ impl Module {
.map(|&s| s.into())
.collect::<StaticVec<_>>();
let return_type = if names.len() > arg_types.as_ref().len() {
names.pop().expect("exists")
names.pop().unwrap()
} else {
Default::default()
};
@ -860,7 +860,7 @@ impl Module {
let comments = comments.as_ref();
if !comments.is_empty() {
let f = self.functions.get_mut(&hash).expect("exists");
let f = self.functions.get_mut(&hash).unwrap();
f.comments = Some(comments.iter().map(|s| s.as_ref().into()).collect());
}
@ -1569,11 +1569,11 @@ impl Module {
match aliases.len() {
0 => (),
1 => {
let alias = aliases.pop().expect("not empty");
let alias = aliases.pop().unwrap();
module.set_var(alias, value);
}
_ => {
let last_alias = aliases.pop().expect("not empty");
let last_alias = aliases.pop().unwrap();
aliases.into_iter().for_each(|alias| {
module.set_var(alias, value.clone());
});

View File

@ -326,14 +326,14 @@ fn optimize_stmt_block(
&& !last_stmt.returns_value() =>
{
state.set_dirty();
statements.pop().expect(">= 2 elements");
statements.pop().unwrap();
}
// { ...; return val; } -> { ...; val }
[.., Stmt::Return(options, ref mut expr, pos)]
if reduce_return && !options.contains(AST_OPTION_BREAK_OUT) =>
{
state.set_dirty();
*statements.last_mut().expect(">= 2 elements") = expr
*statements.last_mut().unwrap() = expr
.as_mut()
.map_or_else(|| Stmt::Noop(pos), |e| Stmt::Expr(mem::take(e)));
}
@ -350,10 +350,9 @@ fn optimize_stmt_block(
{
state.set_dirty();
if second_last_stmt.returns_value() {
*statements.last_mut().expect(">= 2 elements") =
Stmt::Noop(last_stmt.position());
*statements.last_mut().unwrap() = Stmt::Noop(last_stmt.position());
} else {
statements.pop().expect(">= 2 elements");
statements.pop().unwrap();
}
}
_ => break,
@ -371,7 +370,7 @@ fn optimize_stmt_block(
if reduce_return && !options.contains(AST_OPTION_BREAK_OUT) =>
{
state.set_dirty();
statements.pop().expect(">= 2 elements");
statements.pop().unwrap();
}
// { ...; return pure_val; } -> { ... }
[.., Stmt::Return(options, Some(ref expr), _)]
@ -380,11 +379,11 @@ fn optimize_stmt_block(
&& expr.is_pure() =>
{
state.set_dirty();
statements.pop().expect(">= 2 elements");
statements.pop().unwrap();
}
[.., ref last_stmt] if is_pure(last_stmt) => {
state.set_dirty();
statements.pop().expect("not empty");
statements.pop().unwrap();
}
_ => break,
}
@ -431,10 +430,8 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
let value = mem::take(&mut x2.args[1]);
if let Expr::Stack(slot, pos) = value {
x.2 = Expr::from_dynamic(
mem::take(x2.constants.get_mut(slot).expect("valid slot")),
pos,
);
x.2 =
Expr::from_dynamic(mem::take(x2.constants.get_mut(slot).unwrap()), pos);
} else {
x.2 = value;
}
@ -502,7 +499,7 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
// switch const { ... }
Stmt::Switch(match_expr, x, pos) if match_expr.is_constant() => {
let value = match_expr.get_literal_value().expect("constant");
let value = match_expr.get_literal_value().unwrap();
let hasher = &mut get_hasher();
value.hash(hasher);
let hash = hasher.finish();
@ -870,13 +867,13 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
(Expr::StringConstant(s, pos), Expr::IntegerConstant(i, _)) if *i >= 0 && (*i as usize) < s.chars().count() => {
// String literal indexing - get the character
state.set_dirty();
*expr = Expr::CharConstant(s.chars().nth(*i as usize).expect("valid index"), *pos);
*expr = Expr::CharConstant(s.chars().nth(*i as usize).unwrap(), *pos);
}
// string[-int]
(Expr::StringConstant(s, pos), Expr::IntegerConstant(i, _)) if *i < 0 && i.checked_abs().map(|n| n as usize <= s.chars().count()).unwrap_or(false) => {
// String literal indexing - get the character
state.set_dirty();
*expr = Expr::CharConstant(s.chars().rev().nth(i.abs() as usize - 1).expect("valid index"), *pos);
*expr = Expr::CharConstant(s.chars().rev().nth(i.abs() as usize - 1).unwrap(), *pos);
}
// var[rhs]
(Expr::Variable(_, _, _), rhs) => optimize_expr(rhs, state, true),
@ -920,7 +917,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
#[cfg(not(feature = "no_index"))]
Expr::Array(_, _) if expr.is_constant() => {
state.set_dirty();
*expr = Expr::DynamicConstant(expr.get_literal_value().expect("constant").into(), expr.position());
*expr = Expr::DynamicConstant(expr.get_literal_value().unwrap().into(), expr.position());
}
// [ items .. ]
#[cfg(not(feature = "no_index"))]
@ -929,7 +926,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
#[cfg(not(feature = "no_object"))]
Expr::Map(_, _) if expr.is_constant() => {
state.set_dirty();
*expr = Expr::DynamicConstant(expr.get_literal_value().expect("constant").into(), expr.position());
*expr = Expr::DynamicConstant(expr.get_literal_value().unwrap().into(), expr.position());
}
// #{ key:value, .. }
#[cfg(not(feature = "no_object"))]
@ -997,7 +994,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
=> {
let arg_values = &mut x.args.iter().map(|e| match e {
Expr::Stack(slot, _) => x.constants[*slot].clone(),
_ => e.get_literal_value().expect("constant")
_ => e.get_literal_value().unwrap()
}).collect::<StaticVec<_>>();
let arg_types: StaticVec<_> = arg_values.iter().map(Dynamic::type_id).collect();
@ -1024,7 +1021,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
let lib = &[];
let context = (state.engine, x.name.as_str(), lib).into();
let (first, second) = arg_values.split_first_mut().expect("not empty");
let (first, second) = arg_values.split_first_mut().unwrap();
(f)(context, &mut [ first, &mut second[0] ]).ok()
}) {
state.set_dirty();
@ -1063,7 +1060,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
if !has_script_fn {
let arg_values = &mut x.args.iter().map(|e| match e {
Expr::Stack(slot, _) => x.constants[*slot].clone(),
_ => e.get_literal_value().expect("constant")
_ => e.get_literal_value().unwrap()
}).collect::<StaticVec<_>>();
let result = match x.name.as_str() {
@ -1098,7 +1095,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, chaining: bool) {
// constant-name
Expr::Variable(_, pos, x) if x.1.is_none() && state.find_constant(&x.2).is_some() => {
// Replace constant with value
*expr = Expr::from_dynamic(state.find_constant(&x.2).expect("exists").clone(), *pos);
*expr = Expr::from_dynamic(state.find_constant(&x.2).unwrap().clone(), *pos);
state.set_dirty();
}

View File

@ -178,7 +178,7 @@ mod string_functions {
#[rhai_fn(name = "to_upper")]
pub fn to_upper_char(character: char) -> char {
let mut stream = character.to_uppercase();
let ch = stream.next().expect("not empty");
let ch = stream.next().unwrap();
if stream.next().is_some() {
character
} else {
@ -192,7 +192,7 @@ mod string_functions {
#[rhai_fn(name = "to_lower")]
pub fn to_lower_char(character: char) -> char {
let mut stream = character.to_lowercase();
let ch = stream.next().expect("not empty");
let ch = stream.next().unwrap();
if stream.next().is_some() {
character
} else {

View File

@ -1304,11 +1304,7 @@ fn parse_primary(
Token::Custom(key) | Token::Reserved(key) | Token::Identifier(key)
if state.engine.custom_syntax.contains_key(&**key) =>
{
let (key, syntax) = state
.engine
.custom_syntax
.get_key_value(&**key)
.expect("exists");
let (key, syntax) = state.engine.custom_syntax.get_key_value(&**key).unwrap();
let (_, pos) = input.next().expect(NEVER_ENDS);
let settings2 = settings.level_up();
parse_custom_syntax(input, state, lib, settings2, key, syntax, pos)?
@ -1714,11 +1710,7 @@ fn make_assignment_stmt(
Expr::Variable(i, var_pos, ref x) => {
let (index, _, name) = x.as_ref();
let index = i.map_or_else(
|| {
index
.expect("the long index is `Some` when the short index is `None`")
.get()
},
|| index.expect("either long or short index is `None`").get(),
|n| n.get() as usize,
);
match state.stack[state.stack.len() - index].1 {
@ -2013,8 +2005,8 @@ fn parse_binary_op(
| Token::GreaterThanEqualsTo => FnCallExpr { args, ..op_base }.into_fn_call_expr(pos),
Token::Or => {
let rhs = args.pop().expect("two arguments");
let current_lhs = args.pop().expect("two arguments");
let rhs = args.pop().unwrap();
let current_lhs = args.pop().unwrap();
Expr::Or(
BinaryExpr {
lhs: current_lhs.ensure_bool_expr()?,
@ -2025,8 +2017,8 @@ fn parse_binary_op(
)
}
Token::And => {
let rhs = args.pop().expect("two arguments");
let current_lhs = args.pop().expect("two arguments");
let rhs = args.pop().unwrap();
let current_lhs = args.pop().unwrap();
Expr::And(
BinaryExpr {
lhs: current_lhs.ensure_bool_expr()?,
@ -3026,7 +3018,7 @@ fn parse_try_catch(
if err_var.is_some() {
// Remove the error variable from the stack
state.stack.pop().expect("not empty");
state.stack.pop().unwrap();
}
Ok(Stmt::TryCatch(

View File

@ -565,7 +565,7 @@ where
) -> RhaiResultOf<V::Value> {
// Deserialize each value item coming out of the iterator.
seed.deserialize(&mut DynamicDeserializer::from_dynamic(
self.values.next().expect("exists"),
self.values.next().unwrap(),
))
}
}

View File

@ -1216,7 +1216,7 @@ pub fn parse_string_literal(
#[cfg(not(feature = "no_position"))]
{
let start_position = start.position().expect("start position");
let start_position = start.position().unwrap();
skip_whitespace_until = start_position + 1;
}
}
@ -1237,8 +1237,7 @@ pub fn parse_string_literal(
// Whitespace to skip
#[cfg(not(feature = "no_position"))]
_ if next_char.is_whitespace()
&& pos.position().expect("position") < skip_whitespace_until => {}
_ if next_char.is_whitespace() && pos.position().unwrap() < skip_whitespace_until => {}
// All other characters
_ => {
@ -1632,7 +1631,7 @@ fn get_next_token_inner(
|(err, err_pos)| (Token::LexError(err), err_pos),
|(result, _)| {
let mut chars = result.chars();
let first = chars.next().expect("not empty");
let first = chars.next().unwrap();
if chars.next().is_some() {
(

View File

@ -300,7 +300,7 @@ impl EvalAltResult {
format!("{:?}", self)
.split('(')
.next()
.expect("debug format of error is `ErrorXXX(...)`")
.expect("`ErrorXXX(...)`")
.into(),
);

View File

@ -60,7 +60,7 @@ impl StringsInterner {
};
if dict.contains_key(text.as_ref()) {
dict.get(text.as_ref()).expect("exists").clone()
dict.get(text.as_ref()).unwrap().clone()
} else {
let value: ImmutableString = mapper(text.as_ref()).into();
dict.insert(text.as_ref().into(), value.clone());

View File

@ -406,7 +406,7 @@ impl<'a> Scope<'a> {
self.push(name, value);
}
Some((index, AccessMode::ReadWrite)) => {
let value_ref = self.values.get_mut(index).expect("valid index");
let value_ref = self.values.get_mut(index).unwrap();
*value_ref = Dynamic::from(value);
}
}
@ -446,7 +446,7 @@ impl<'a> Scope<'a> {
}
Some((_, AccessMode::ReadOnly)) => panic!("variable {} is constant", name.as_ref()),
Some((index, AccessMode::ReadWrite)) => {
let value_ref = self.values.get_mut(index).expect("valid index");
let value_ref = self.values.get_mut(index).unwrap();
*value_ref = Dynamic::from(value);
}
}
@ -492,7 +492,7 @@ impl<'a> Scope<'a> {
#[inline]
#[must_use]
pub(crate) fn get_mut_by_index(&mut self, index: usize) -> &mut Dynamic {
self.values.get_mut(index).expect("valid index")
self.values.get_mut(index).unwrap()
}
/// Add an alias to an entry in the [`Scope`].
///
@ -502,7 +502,7 @@ impl<'a> Scope<'a> {
#[cfg(not(feature = "no_module"))]
#[inline]
pub(crate) fn add_entry_alias(&mut self, index: usize, alias: Identifier) -> &mut Self {
let (_, aliases) = self.names.get_mut(index).expect("valid index");
let (_, aliases) = self.names.get_mut(index).unwrap();
match aliases {
None => {
let mut list = StaticVec::new_const();