Skip to content

Commit

Permalink
fix lowering of TypeVars in DataType declations
Browse files Browse the repository at this point in the history
have lowering emit the correct TypeVar expression
instead of fixing it in the DataType constructor
  • Loading branch information
vtjnash committed May 12, 2016
1 parent 98159c7 commit fa6e751
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,12 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la
jl_datatype_t *dt = NULL;
JL_GC_PUSH4(&para, &super, &temp, &dt);
temp = eval(args[2], locals, lam); // field names
for(size_t i=0; i < jl_svec_len(para); i++) {
((jl_tvar_t*)jl_svecref(para,i))->bound = 0;
#ifndef NDEBUG
size_t i, l = jl_svec_len(para);
for (i = 0; i < l; i++) {
assert(!((jl_tvar_t*)jl_svecref(para, i))->bound);
}
#endif
dt = jl_new_datatype((jl_sym_t*)name, jl_any_type, (jl_svec_t*)para,
(jl_svec_t*)temp, NULL,
0, args[5]==jl_true ? 1 : 0, jl_unbox_long(args[6]));
Expand Down
4 changes: 2 additions & 2 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@
(block
(global ,name) (const ,name)
,@(map (lambda (v) `(local ,v)) params)
,@(map make-assignment params (symbols->typevars params bounds #t))
,@(map make-assignment params (symbols->typevars params bounds #f))
(composite_type ,name (call (core svec) ,@params)
(call (core svec) ,@(map (lambda (x) `',x) field-names))
,super (call (core svec) ,@field-types) ,mut ,min-initialized)))
Expand Down Expand Up @@ -2487,7 +2487,7 @@ f(x) = yt(x)
((,@(map (lambda (p) `(,p Any 18)) P))
() 0 ())
(body (global ,name) (const ,name)
,@(map (lambda (p) `(= ,p (call (core TypeVar) ',p (core Any) true))) P)
,@(map (lambda (p) `(= ,p (call (core TypeVar) ',p (core Any) false))) P)
(composite_type ,name (call (core svec) ,@P)
(call (core svec) ,@(map (lambda (v) `',v) fields))
,super
Expand Down

0 comments on commit fa6e751

Please sign in to comment.