Repository: nushell/nushell
File: crates/nu-parser/src/parse_keywords.rs (Rust)

Code before:
                },
            ) = call.positional_nth(2)
            {
                {
                    let block = working_set.get_block_mut(*block_id);

                    block.signature = Box::new(sig);
                }
            }

            (call, call_span)
        }
    };

    // All positional arguments must be in the call positional vector by this point
    let var_decl = call.positional_nth(0).expect("for call already checked");
    let iteration_expr = call.positional_nth(1).expect("for call already checked");
    let block = call.positional_nth(2).expect("for call already checked");

    let iteration_expr_ty = iteration_expr.ty.clone();

    // Figure out the type of the variable the `for` uses for iteration
    let var_type = match iteration_expr_ty {
        Type::List(x) => *x,
        Type::Table(x) => Type::Record(x),
        Type::Range => Type::Any, // Range elements can be int or float
        x => x,
    };

    if let (Some(var_id), Some(block_id)) = (&var_decl.as_var(), block.as_block()) {
        working_set.set_variable_type(*var_id, var_type.clone());

        let block = working_set.get_block_mut(block_id);

        block.signature.required_positional.insert(
            0,
            PositionalArg {
                name: String::new(),
                desc: String::new(),
                shape: var_type.to_shape(),
                var_id: Some(*var_id),
                default_value: None,
            },
        );
    }

    Expression::new(working_set, Expr::Call(call), call_span, Type::Nothing)
}

/// If `name` is a keyword, emit an error.
fn verify_not_reserved_variable_name(working_set: &mut StateWorkingSet, name: &str, span: Span) {

Review comment (suggestion):
Not sure if there's a better approach here, `Type::Any` made the test case pass
```suggestion
        Type::Range => Type::Number, // Range elements can be int or float
```

Code after:
                return Expression::new(working_set, Expr::Call(call), call_span, output);
            }

            // Let's get our block and make sure it has the right signature
            if let Some(
                Expression {
                    expr: Expr::Block(block_id),
                    ..
                }
                | Expression {
                    expr: Expr::RowCondition(block_id),
                    ..
                },
            ) = call.positional_nth(2)
            {
                {
                    let block = working_set.get_block_mut(*block_id);

                    block.signature = Box::new(sig);
                }
            }

            (call, call_span)
        }
    };

    // All positional arguments must be in the call positional vector by this point
    let var_decl = call.positional_nth(0).expect("for call already checked");
    let iteration_expr = call.positional_nth(1).expect("for call already checked");
    let block = call.positional_nth(2).expect("for call already checked");

    let iteration_expr_ty = iteration_expr.ty.clone();

    // Figure out the type of the variable the `for` uses for iteration
    let var_type = match iteration_expr_ty {
        Type::List(x) => *x,
        Type::Table(x) => Type::Record(x),
        Type::Range => Type::Number, // Range elements can be int or float
        x => x,
    };

    if let (Some(var_id), Some(block_id)) = (&var_decl.as_var(), block.as_block()) {
        working_set.set_variable_type(*var_id, var_type.clone());

        let block = working_set.get_block_mut(block_id);

        block.signature.required_positional.insert(
            0,
            PositionalArg {
                name: String::new(),
                desc: String::new(),