Skip to content

Commit e6400ab

Browse files
committed
fix some cases of compile-time evaluation with interpreter changes
1 parent 1bc0168 commit e6400ab

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/interpreter.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la
132132
}
133133
if (jl_is_gensym(e)) {
134134
ssize_t genid = ((jl_gensym_t*)e)->id;
135-
if (genid >= jl_linfo_ngensyms(lam) || genid < 0)
135+
if (genid >= jl_linfo_ngensyms(lam) || genid < 0 || locals == NULL)
136136
jl_error("access to invalid GenSym location");
137137
else
138138
return locals[jl_linfo_nslots(lam) + genid];
@@ -150,7 +150,7 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la
150150
if (!jl_is_expr(e)) {
151151
if (jl_typeis(e, jl_slot_type)) {
152152
ssize_t n = jl_slot_number(e);
153-
if (n > jl_linfo_nslots(lam) || n < 1)
153+
if (n > jl_linfo_nslots(lam) || n < 1 || locals == NULL)
154154
jl_error("access to invalid slot number");
155155
jl_value_t *v = locals[n-1];
156156
if (v == NULL)

src/intrinsics.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,11 @@ static jl_value_t *staticeval_bitstype(jl_value_t *targ, const char *fname, jl_c
350350
bt = jl_tparam0(et);
351351
}
352352
else {
353-
bt = try_eval(targ, ctx, NULL); // TODO: change this to an actual call to staticeval rather than actually executing code
353+
bt = jl_static_eval(targ, ctx, ctx->module, ctx->linfo, true, true);
354354
if (bt) jl_add_linfo_root(ctx->linfo, bt);
355355
}
356-
if (fname && (!bt || !jl_is_bitstype(bt))) {
357-
jl_errorf("%s: expected bits type as first argument", fname);
356+
if (!bt || !jl_is_bitstype(bt)) {
357+
emit_error("expected bits type as first argument", ctx);
358358
return NULL;
359359
}
360360
return bt;

0 commit comments

Comments
 (0)