Docstring some intricacies around SyntaxShape (#10544)

Inspired by @fdncred and @amtoine's questions
https://github.com/nushell/nushell/pull/10512#issuecomment-1739996967
This commit is contained in:
Stefan Holderbach
2023-09-29 16:35:22 +02:00
committed by GitHub
parent 7ad4c679b3
commit f2af12af2c
2 changed files with 32 additions and 7 deletions

View File

@ -2696,7 +2696,15 @@ pub fn parse_string_strict(working_set: &mut StateWorkingSet, span: Span) -> Exp
}
}
//TODO: Handle error case for unknown shapes
/// Parse the literals of [`Type`]-like [`SyntaxShape`]s including inner types.
/// Also handles the specification of custom completions with `type@completer`.
///
/// Used in:
/// - `: ` argument type (+completer) positions in signatures
/// - `type->type` input/output type pairs
/// - `let name: type` variable type infos
///
/// NOTE: Does not provide a mapping to every [`SyntaxShape`]
pub fn parse_shape_name(
working_set: &mut StateWorkingSet,
bytes: &[u8],
@ -2757,6 +2765,7 @@ pub fn parse_shape_name(
return shape;
}
} else {
//TODO: Handle error case for unknown shapes
working_set.error(ParseError::UnknownType(span));
return SyntaxShape::Any;
}