If TestError() is called on a built-in/UDF that does not have a Prepare() stage, GetValue() in expr-test.cc never gets to call the corresponding function for that built-in/UDF. This is because it assumes that if any error exists, it is found in the Prepare() stage and never actually executes the actual function.
The builtin regexp_extract() is evaluated by executing the following functions:
StringFunctions::RegexpExtract() (x num rows) ->
When we test for an error(expect_error = true) in expr-test.cc:GetValue(), it calls executor_->Exec() which ultimately calls only the Prepare() function(RegexpPrepare()) and never calls executor_->FetchResult() which would ultimately call the actual function(RegexpExtract()).