nushell/crates/nu-parser/src
WindSoilder bf40f035f6
don't overrite arg's type if it's annotated explicitly (#10424)
# Description
Fixes: #10410 

So the following script is possible:
```nushell
def a [b: any = null] { let b = ($b | default "default_b"); }
a "given_b"
```

## About the change
When parsing signature, and nushell meets something like `a: any`, it
force the parser to treat `a` as `any` type. This is what
`arg_explicit_type` means, it's only set when we goes into
`ParseMode::TypeMode`, and it will be reset to `false` if the token goes
to next argument.

so, when we have something like this: `def a [b: any = null] { $b }`,
the type of `$b` won't be overwritten.

But if we have something like this: `def a [b = null] { $b }`, the type
of `$b` is not annotated, so we make it to be `nothing`(which is the
type of null)
2023-09-21 03:58:29 +12:00
..
deparse.rs allow empty string arguments (#9420) 2023-06-13 07:30:30 -05:00
flatten.rs Avoid blocking when o+e> redirects too much stderr message (#8784) 2023-05-17 17:47:03 -05:00
known_external.rs Sort entries in scope commands; Fix usage of externs (#10039) 2023-08-17 16:37:01 +02:00
lex.rs allow comment in multiple line pipeline (#9436) 2023-06-15 13:11:42 +02:00
lib.rs Allow parse-time evaluation of calls, pipelines and subexpressions (#9499) 2023-08-26 16:41:29 +03:00
lite_parser.rs skip comments and eols while parsing pipeline (#10149) 2023-08-30 13:24:13 -05:00
parse_keywords.rs Invert &Options to Option<&T> (#10315) 2023-09-13 07:00:58 +08:00
parse_patterns.rs add match guards (#9621) 2023-07-16 12:25:12 +12:00
parser_path.rs Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
parser.rs don't overrite arg's type if it's annotated explicitly (#10424) 2023-09-21 03:58:29 +12:00
type_check.rs Remove python-like string multiplication (#10293) 2023-09-13 19:52:04 +12:00