Skip to content

Commit

Permalink
fix some cases of compile-time evaluation with interpreter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Mar 19, 2016
1 parent 8899b9b commit a6213c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la
}
if (jl_is_gensym(e)) {
ssize_t genid = ((jl_gensym_t*)e)->id;
if (genid >= jl_linfo_ngensyms(lam) || genid < 0)
if (genid >= jl_linfo_ngensyms(lam) || genid < 0 || locals == NULL)
jl_error("access to invalid GenSym location");
else
return locals[jl_linfo_nslots(lam) + genid];
Expand All @@ -150,7 +150,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la
if (!jl_is_expr(e)) {
if (jl_typeis(e, jl_slot_type)) {
ssize_t n = jl_slot_number(e);
if (n > jl_linfo_nslots(lam) || n < 1)
if (n > jl_linfo_nslots(lam) || n < 1 || locals == NULL)
jl_error("access to invalid slot number");
jl_value_t *v = locals[n-1];
if (v == NULL)
Expand Down
6 changes: 3 additions & 3 deletions src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ static jl_value_t *staticeval_bitstype(jl_value_t *targ, const char *fname, jl_c
bt = jl_tparam0(et);
}
else {
bt = try_eval(targ, ctx, NULL); // TODO: change this to an actual call to staticeval rather than actually executing code
bt = jl_static_eval(targ, ctx, ctx->module, ctx->linfo, true, true);
if (bt) jl_add_linfo_root(ctx->linfo, bt);
}
if (fname && (!bt || !jl_is_bitstype(bt))) {
jl_errorf("%s: expected bits type as first argument", fname);
if (!bt || !jl_is_bitstype(bt)) {
emit_error("expected bits type as first argument", ctx);
return NULL;
}
return bt;
Expand Down

0 comments on commit a6213c2

Please sign in to comment.