`@test_throws ArgumentError throw(ArgumentError)` fails

I seem to be missing something obvious here—why does the following test fail in v1.8.2?

julia> using Test

julia> @test_throws ArgumentError throw(ArgumentError)
Test Failed at REPL[3]:1
  Expression: throw(ArgumentError)
    Expected: ArgumentError
      Thrown: DataType
ERROR: There was an error during testing

julia> throw(ArgumentError)
ERROR: ArgumentError
 [1] top-level scope
   @ REPL[4]:1

You need to instantiate ArgumentError for this to work:

julia> @test_throws ArgumentError throw(ArgumentError("hi"))
Test Passed
      Thrown: ArgumentError
1 Like