Commit 1c40a35a
1c40a35a6ea1Merged
Ryan Seys <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
codegen: diagnose eval of a runtime string
eval("...") and Kernel.eval("...") compiling an arbitrary runtime
string is a hard AOT boundary, not a missing feature. They previously
fell through to a generic unsupported-call dump. Emit an intentional
diagnostic ("eval of a runtime string is not supported by AOT
compilation; define the code statically") for the common forms
(x = eval(s), bare eval(s)).
The instance_eval / class_eval / module_eval block forms carry a literal block, not a string, and are handled separately -- unaffected.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 1c40a35a6ea1
- Parent
- b1e4d47607fd
src/codegen_call.cmodifiedView file
@@ -3448,6 +3448,17 @@
34483448
buf_puts(b, ")");34493449
return;34503450
}3451+
/* eval(string) / Kernel.eval(string): compiling an arbitrary runtime string is3452+
a hard AOT boundary, not a missing feature. Emit an intentional diagnostic.3453+
(The instance_eval/class_eval/module_eval block forms are handled separately3454+
and are unaffected -- those carry a literal block, not a string.) */3455+
if (!strcmp(name, "eval") && argc >= 1 &&3456+
(recv < 0 || (nt_type(nt, recv) &&3457+
(!strcmp(nt_type(nt, recv), "ConstantReadNode") || !strcmp(nt_type(nt, recv), "ConstantPathNode")) &&3458+
nt_str(nt, recv, "name") && !strcmp(nt_str(nt, recv, "name"), "Kernel")))) {3459+
unsupported(c, id, "eval of a runtime string is not supported by AOT compilation (define the code statically)");3460+
return;3461+
}34513462
if (recv < 0 && !strcmp(name, "loop") && argc == 0) {34523463
int blk = nt_ref(nt, id, "block");34533464
if (blk >= 0) {