diff --git a/crates/nu-parser/src/type_check.rs b/crates/nu-parser/src/type_check.rs index a9f54f59eb..53dbcd3f95 100644 --- a/crates/nu-parser/src/type_check.rs +++ b/crates/nu-parser/src/type_check.rs @@ -8,6 +8,8 @@ use nu_protocol::{ pub fn type_compatible(lhs: &Type, rhs: &Type) -> bool { match (lhs, rhs) { (Type::List(c), Type::List(d)) => type_compatible(c, d), + (Type::Number, Type::Int) => true, + (Type::Number, Type::Float) => true, (Type::Unknown, _) => true, (_, Type::Unknown) => true, (lhs, rhs) => lhs == rhs, diff --git a/src/tests/test_type_check.rs b/src/tests/test_type_check.rs index 320836b805..ae93ceb37d 100644 --- a/src/tests/test_type_check.rs +++ b/src/tests/test_type_check.rs @@ -14,3 +14,13 @@ fn type_in_list_of_this_type() -> TestResult { fn type_in_list_of_non_this_type() -> TestResult { fail_test(r#"'hello' in [41 42 43]"#, "mismatched for operation") } + +#[test] +fn number_int() -> TestResult { + run_test(r#"def foo [x:number] { $x }; foo 1"#, "1") +} + +#[test] +fn number_float() -> TestResult { + run_test(r#"def foo [x:number] { $x }; foo 1.4"#, "1.4") +}