forked from extern/nushell
@ -676,7 +676,13 @@ impl FallibleColorSyntax for CommandHeadShape {
|
||||
if context.registry.has(name) {
|
||||
// If the registry has the command, color it as an internal command
|
||||
token_nodes.color_shape(FlatShape::InternalCommand.spanned(text));
|
||||
let signature = context.registry.get(name).unwrap();
|
||||
let signature = context.registry.get(name).ok_or_else(|| {
|
||||
ShellError::labeled_error(
|
||||
"Internal error: could not load signature from registry",
|
||||
"could not load from registry",
|
||||
text,
|
||||
)
|
||||
})?;
|
||||
Ok(CommandHeadKind::Internal(signature))
|
||||
} else {
|
||||
// Otherwise, color it as an external command
|
||||
@ -716,7 +722,9 @@ impl ExpandSyntax for CommandHeadShape {
|
||||
UnspannedToken::Bare => {
|
||||
let name = token_span.slice(context.source);
|
||||
if context.registry.has(name) {
|
||||
let signature = context.registry.get(name).unwrap();
|
||||
let signature = context.registry.get(name).ok_or_else(|| {
|
||||
ParseError::internal_error(name.spanned(token_span))
|
||||
})?;
|
||||
CommandSignature::Internal(signature.spanned(token_span))
|
||||
} else {
|
||||
CommandSignature::External(token_span)
|
||||
|
@ -683,7 +683,11 @@ impl ExpandSyntax for IntMemberShape {
|
||||
UnspannedAtomicToken::Number {
|
||||
number: RawNumber::Int(int),
|
||||
} => Ok(Member::Int(
|
||||
BigInt::from_str(int.slice(context.source)).unwrap(),
|
||||
BigInt::from_str(int.slice(context.source)).map_err(|_| {
|
||||
ParseError::internal_error(
|
||||
"can't convert from string to big int".spanned(int),
|
||||
)
|
||||
})?,
|
||||
int,
|
||||
)),
|
||||
|
||||
@ -732,7 +736,9 @@ impl ExpandSyntax for MemberShape {
|
||||
|
||||
if let Some(peeked) = number {
|
||||
let node = peeked.not_eof("column")?.commit();
|
||||
let (n, span) = node.as_number().unwrap();
|
||||
let (n, span) = node.as_number().ok_or_else(|| {
|
||||
ParseError::internal_error("can't convert node to number".spanned(node.span()))
|
||||
})?;
|
||||
|
||||
return Ok(Member::Number(n, span))
|
||||
}*/
|
||||
@ -741,7 +747,9 @@ impl ExpandSyntax for MemberShape {
|
||||
|
||||
if let Some(peeked) = string {
|
||||
let node = peeked.not_eof("column")?.commit();
|
||||
let (outer, inner) = node.as_string().unwrap();
|
||||
let (outer, inner) = node.as_string().ok_or_else(|| {
|
||||
ParseError::internal_error("can't convert node to string".spanned(node.span()))
|
||||
})?;
|
||||
|
||||
return Ok(Member::String(outer, inner));
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ impl<'content, 'me> std::ops::Drop for Checkpoint<'content, 'me> {
|
||||
pub struct Peeked<'content, 'me> {
|
||||
pub(crate) node: Option<&'content TokenNode>,
|
||||
iterator: &'me mut TokensIterator<'content>,
|
||||
from: usize,
|
||||
to: usize,
|
||||
pub from: usize,
|
||||
pub to: usize,
|
||||
}
|
||||
|
||||
impl<'content, 'me> Peeked<'content, 'me> {
|
||||
|
Reference in New Issue
Block a user