forked from extern/nushell
Change alias shape inference to proposal of RFC#4 (#2685)
* Change alias shape inference to proposal of RFC#4 * Remove commented code * Fix typo * Change comment to be more informative * Make match statement to lookup in table * Remove resolved question https://github.com/nushell/nushell/pull/2685#discussion_r509832054 * Pick ...or_insert_dependency functions into pieces Previously there was get_shape_of_expr_or_insert dependency, now there is get_shape_of_expr and get_shape_of_expr_or_insert_dependency 2 new functions have been added: get_result_shape_of_math_expr and get_result_shape_of_math_expr_or_insert_dependency * Remove flattening of deep binary expressions Previously deep binary expressions have been flattened through the insertion of fake vars. This logic was quite complicated. Now if a variable depends on the result shape of a binary expression and the result shape can't be computed, the variable simply depends on the whole binary. * Change Expression::Variable(Variable::It(...)) to Expression::Variable(...) * Simplify get_result_shapes_in_math_expr * Simplify infer_shapes_in_binary_expr * Clarify comment * Clarify comment * Fix clippy lint * Move check for real var into checked_insert * Remove comment * Rename var
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
use crate::hir::Block;
|
||||
use crate::value::Value;
|
||||
use crate::SyntaxShape;
|
||||
use crate::{value::Value, Signature};
|
||||
use nu_errors::ShellError;
|
||||
use nu_source::{b, DebugDocBuilder, PrettyDebug};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -23,7 +22,8 @@ pub enum CommandAction {
|
||||
/// Enter the help shell, which allows exploring the help system
|
||||
EnterHelpShell(Value),
|
||||
/// Add an alias command
|
||||
AddAlias(String, Vec<(String, SyntaxShape)>, Block),
|
||||
/// Note: We are passing the Signature in a Box to decrease the memory size of AddAlias
|
||||
AddAlias(Box<Signature>, Block),
|
||||
/// Add plugins from path given
|
||||
AddPlugins(String),
|
||||
/// Go to the previous shell in the shell ring buffer
|
||||
|
@ -26,7 +26,7 @@ impl NamedType {
|
||||
}
|
||||
|
||||
/// The type of positional arguments
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum PositionalType {
|
||||
/// A mandatory positional argument with the expected shape of the value
|
||||
Mandatory(String, SyntaxShape),
|
||||
|
@ -2,7 +2,7 @@ use nu_source::{b, DebugDocBuilder, PrettyDebug};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The syntactic shapes that values must match to be passed into a command. You can think of this as the type-checking that occurs when you call a function.
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||
pub enum SyntaxShape {
|
||||
/// Any syntactic form is allowed
|
||||
Any,
|
||||
|
Reference in New Issue
Block a user