run ensure_flag_arg_type for short flag values (#14074)

Closes #13654

# User-Facing Changes

- Short flags are now fully type-checked,
  including null and record signatures for literal arguments:

```nushell
def test [-v: record<l: int>] {};
test -v null # error
test -v {l: ""} # error

def test2 [-v: int] {};
let v = ""
test2 -v $v # error
```

- `polars unpivot` `--index`/`--on` and `into value --columns`
now accept `list` values
This commit is contained in:
Solomon
2024-10-17 02:25:17 +00:00
committed by sholderbach
parent 3af575cce7
commit b0427ca9ff
4 changed files with 28 additions and 19 deletions

View File

@ -1067,30 +1067,27 @@ pub fn parse_internal_call(
if let Some(arg_shape) = flag.arg {
if let Some(arg) = spans.get(spans_idx + 1) {
let arg = parse_value(working_set, *arg, &arg_shape);
let (arg_name, val_expression) = ensure_flag_arg_type(
working_set,
flag.long.clone(),
arg.clone(),
&arg_shape,
spans[spans_idx],
);
if flag.long.is_empty() {
if let Some(short) = flag.short {
call.add_named((
Spanned {
item: String::new(),
span: spans[spans_idx],
},
arg_name,
Some(Spanned {
item: short.to_string(),
span: spans[spans_idx],
}),
Some(arg),
Some(val_expression),
));
}
} else {
call.add_named((
Spanned {
item: flag.long.clone(),
span: spans[spans_idx],
},
None,
Some(arg),
));
call.add_named((arg_name, None, Some(val_expression)));
}
spans_idx += 1;
} else {