From d777bccb870bf71355ac37299cb2d6bf31d51899 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 25 May 2015 01:48:49 -0400 Subject: [PATCH] fix #11278, restore check that field types are Types, lost in #10380 --- src/builtins.c | 6 ++++++ src/interpreter.c | 6 +++++- src/julia_internal.h | 1 - src/toplevel.c | 6 ------ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/builtins.c b/src/builtins.c index ccf1a016d6111..aaec4de02fa66 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -1005,6 +1005,12 @@ JL_CALLABLE(jl_f_union) // generic function reflection ------------------------------------------------ +static void jl_check_type_tuple(jl_value_t *t, jl_sym_t *name, const char *ctx) +{ + if (!jl_is_tuple_type(t)) + jl_type_error_rt(name->name, ctx, (jl_value_t*)jl_type_type, t); +} + JL_CALLABLE(jl_f_methodexists) { JL_NARGS(method_exists, 2, 2); diff --git a/src/interpreter.c b/src/interpreter.c index 2f4494fc7030c..46006808a84d2 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -410,7 +410,11 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, size_t nl, size_t ng dt->types = (jl_svec_t*)eval(args[4], locals, nl, ngensym); gc_wb(dt, dt->types); inside_typedef = 0; - //jl_check_type_tuple(dt->types, dt->name->name, "type definition"); + for(size_t i=0; i < jl_svec_len(dt->types); i++) { + jl_value_t *elt = jl_svecref(dt->types, i); + if (!jl_is_type(elt) && !jl_is_typevar(elt)) + jl_type_error_rt(dt->name->name->name, "type definition", (jl_value_t*)jl_type_type, elt); + } super = eval(args[3], locals, nl, ngensym); jl_set_datatype_super(dt, super); } diff --git a/src/julia_internal.h b/src/julia_internal.h index a75feae456d1a..0115aa09bad61 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -49,7 +49,6 @@ uint32_t jl_get_gs_ctr(void); void jl_set_gs_ctr(uint32_t ctr); void NORETURN jl_no_method_error(jl_function_t *f, jl_value_t **args, size_t na); -void jl_check_type_tuple(jl_value_t *t, jl_sym_t *name, const char *ctx); #define JL_CALLABLE(name) \ DLLEXPORT jl_value_t *name(jl_value_t *F, jl_value_t **args, uint32_t nargs) diff --git a/src/toplevel.c b/src/toplevel.c index 453872696c869..ff115071e8fa8 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -613,12 +613,6 @@ DLLEXPORT jl_value_t *jl_load_(jl_value_t *str) void jl_reinstantiate_inner_types(jl_datatype_t *t); -void jl_check_type_tuple(jl_value_t *t, jl_sym_t *name, const char *ctx) -{ - if (!jl_is_tuple_type(t)) - jl_type_error_rt(name->name, ctx, (jl_value_t*)jl_type_type, t); -} - void jl_set_datatype_super(jl_datatype_t *tt, jl_value_t *super) { if (!jl_is_datatype(super) || !jl_is_abstracttype(super) ||