making empty list matches list<int> types (#11596)

# Description
Fixes: #11595

The original issue is caused by #11475, we also need to make empty list
matches `list type` or `table type`

cc @amtoine 

# User-Facing Changes
Nan

# Tests + Formatting
Done
This commit is contained in:
WindSoilder
2024-01-26 22:24:17 +08:00
committed by GitHub
parent d646903161
commit 56acebb826
2 changed files with 31 additions and 7 deletions

View File

@ -229,6 +229,18 @@ fn type_check_for_during_eval2() -> TestResult {
)
}
#[test]
fn empty_list_matches_list_type() -> TestResult {
let _ = run_test(
r#"def spam [foo: list<int>] { echo $foo }; spam [] | length"#,
"0",
);
run_test(
r#"def spam [foo: list<string>] { echo $foo }; spam [] | length"#,
"0",
)
}
#[test]
fn path_argument_dont_auto_expand_if_single_quoted() -> TestResult {
run_test("def spam [foo: path] { echo $foo }; spam '~/aa'", "~/aa")