From 2ad6ee4a6e1b294f10d6915295d9c3eae4802307 Mon Sep 17 00:00:00 2001 From: Alexey Stukalov Date: Wed, 22 Mar 2023 23:56:02 -0700 Subject: [PATCH] Fix 2-arg `@inferred` (#796) * test 2-arg `@inferred` with kwargs * fix #795 * bump version to 3.46.2 --- Project.toml | 2 +- src/Compat.jl | 2 ++ test/runtests.jl | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 870fb4fe5..2e32a9c02 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Compat" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "3.46.1" +version = "3.46.2" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/Compat.jl b/src/Compat.jl index 882429626..6ed1d7b10 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -489,6 +489,8 @@ end # https://github.com/JuliaLang/julia/pull/27516 if VERSION < v"1.2.0-DEV.77" import Test: @inferred + using Test: _args_and_call + using InteractiveUtils: gen_call_with_extracted_types using Core.Compiler: typesubtract macro inferred(allow, ex) diff --git a/test/runtests.jl b/test/runtests.jl index 0dfde8b4c..a1835e51e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -492,6 +492,16 @@ end @test g(10) == 1 @inferred Missing g(9) @inferred Missing g(10) + + @testset "with kwargs (#795)" begin + h(a; b=1) = a < 10 ? missing : b + @test ismissing(h(9)) + @test h(10) == 1 + @inferred Missing h(9) + @inferred Missing h(10) + @inferred Missing h(9; b=2) + @inferred Missing h(10; b=2) + end end # https://github.com/JuliaLang/julia/pull/36360