Skip to content

Commit

Permalink
Revert "improve apply_type error message (#42422)"
Browse files Browse the repository at this point in the history
This reverts commit ada1cd2.
  • Loading branch information
KristofferC committed Oct 29, 2021
1 parent 593357f commit 5183933
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
14 changes: 5 additions & 9 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,7 @@ jl_value_t *jl_apply_type(jl_value_t *tc, jl_value_t **params, size_t n)
}
// if this is a wrapper, let check_datatype_parameters give the error
if (!iswrapper)
jl_type_error_rt(jl_is_datatype(inner) ? jl_symbol_name(inner->name->name) : "Type",
jl_symbol_name(ua->var->name), (jl_value_t*)ua->var, pi);
jl_type_error_rt("Type", jl_symbol_name(ua->var->name), (jl_value_t*)ua->var, pi);
}

tc = jl_instantiate_unionall(ua, pi);
Expand Down Expand Up @@ -1064,19 +1063,16 @@ static void check_datatype_parameters(jl_typename_t *tn, jl_value_t **params, si
}
assert(i == np*2);
wrapper = tn->wrapper;
for (i = 0; i < np; i++) {
for(i=0; i < np; i++) {
assert(jl_is_unionall(wrapper));
jl_tvar_t *tv = ((jl_unionall_t*)wrapper)->var;
if (!within_typevar(params[i], bounds[2*i], bounds[2*i+1])) {
if (tv->lb != bounds[2*i] || tv->ub != bounds[2*i+1])
// pass a new version of `tv` containing the instantiated bounds
tv = jl_new_typevar(tv->name, bounds[2*i], bounds[2*i+1]);
JL_GC_PUSH1(&tv);
// TODO: pass a new version of `tv` containing the instantiated bounds
jl_type_error_rt(jl_symbol_name(tn->name), jl_symbol_name(tv->name), (jl_value_t*)tv, params[i]);
}
int j;
for (j = 2*i + 2; j < 2*np; j++) {
jl_value_t *bj = bounds[j];
for(j=2*i+2; j < 2*np; j++) {
jl_value_t*bj = bounds[j];
if (bj != (jl_value_t*)jl_any_type && bj != jl_bottom_type)
bounds[j] = jl_substitute_var(bj, tv, params[i]);
}
Expand Down
8 changes: 1 addition & 7 deletions test/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ let
@test occursin("column vector", err_str)
end

struct TypeWithIntParam{T<:Integer, Vector{T}<:A<:AbstractArray{T}} end
struct TypeWithIntParam{T <: Integer} end
struct Bounded # not an AbstractArray
bound::Int
end
Expand Down Expand Up @@ -315,14 +315,8 @@ let undefvar
@test err_str == "TypeError: in Type, in parameter, expected Type, got a value of type String"
err_str = @except_str TypeWithIntParam{Any} TypeError
@test err_str == "TypeError: in TypeWithIntParam, in T, expected T<:Integer, got Type{Any}"
err_str = @except_str TypeWithIntParam{Int64,Vector{Float64}} TypeError
@test err_str == "TypeError: in TypeWithIntParam, in A, expected Vector{Int64}<:A<:(AbstractArray{Int64}), got Type{Vector{Float64}}"
err_str = @except_str TypeWithIntParam{Int64}{Vector{Float64}} TypeError
@test err_str == "TypeError: in TypeWithIntParam, in A, expected Vector{Int64}<:A<:(AbstractArray{Int64}), got Type{Vector{Float64}}"
err_str = @except_str Type{Vararg} TypeError
@test err_str == "TypeError: in Type, in parameter, expected Type, got Vararg"
err_str = @except_str Ref{Vararg} TypeError
@test err_str == "TypeError: in Type, in parameter, expected Type, got Vararg"

err_str = @except_str mod(1,0) DivideError
@test err_str == "DivideError: integer division error"
Expand Down

0 comments on commit 5183933

Please sign in to comment.