nushell/crates/nu-parser/src
Stefan Holderbach e427c68731
Relax type-check of key-less table/record (#10629)
# Description
Relax typechecking of key-less `table`/`record`

Assume that they are acceptable for more narrowly specified
`table<...>`/`record<...>` where `...` specifies keys and potentially
types for those keys/columns.

This ensures that you can use commands that specify general return
values statically with more specific input-/args-type requirements.

Reduces the power of the type-check a bit but unlocks you to actually
use the specific annotations in more places.
Incompatibilities will only be raised if an output type declares
specific columns/keys.

Closes #9702

Supersedes #10594 as a simpler solution requiring no extra distinction.

h/t @1kinoti, @NotLebedev
# User-Facing Changes
Now legal at type-check time

```nu
def foo []: nothing -> table { [] }
def foo []: nothing -> table<> { ls }
def bar []: table<a:int,b:string> -> nothing {}

foo | bar 
```

# Tests + Formatting
- 1 explicit test with specified relaxed return type passed to concrete
expected input type
- 1 test leveraging the general output type of a built-in command
- 1 test wrapping a general built-in command and verifying the type
inference in the function body
2023-10-08 13:26:36 +02: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 Move SyntaxShape specifier parsing into own file (#10448) 2023-10-05 23:31:40 +02:00
lite_parser.rs skip comments and eols while parsing pipeline (#10149) 2023-08-30 13:24:13 -05:00
parse_keywords.rs Fix parsing of signature inp/out types in predecls (#10642) 2023-10-08 12:58:26 +02:00
parse_patterns.rs add match guards (#9621) 2023-07-16 12:25:12 +12:00
parse_shape_specs.rs Move SyntaxShape specifier parsing into own file (#10448) 2023-10-05 23:31:40 +02:00
parser_path.rs Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
parser.rs Move SyntaxShape specifier parsing into own file (#10448) 2023-10-05 23:31:40 +02:00
type_check.rs Relax type-check of key-less table/record (#10629) 2023-10-08 13:26:36 +02:00