Commit e47ca2a8

e47ca2a8ba3eMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Merge pull request #1507 from ryanseys/rs-eval-diagnostic

Diagnose eval of a runtime string

Details

Commit
e47ca2a8ba3e
Parent
ac2251005e8f
Merge parent
1c40a35a6ea1

src/codegen_call.cmodifiedView file

@@ -3523,6 +3523,17 @@
35233523 buf_puts(b, ")");
35243524 return;
35253525 }
3526+ /* eval(string) / Kernel.eval(string): compiling an arbitrary runtime string is
3527+ a hard AOT boundary, not a missing feature. Emit an intentional diagnostic.
3528+ (The instance_eval/class_eval/module_eval block forms are handled separately
3529+ and are unaffected -- those carry a literal block, not a string.) */
3530+ if (!strcmp(name, "eval") && argc >= 1 &&
3531+ (recv < 0 || (nt_type(nt, recv) &&
3532+ (!strcmp(nt_type(nt, recv), "ConstantReadNode") || !strcmp(nt_type(nt, recv), "ConstantPathNode")) &&
3533+ nt_str(nt, recv, "name") && !strcmp(nt_str(nt, recv, "name"), "Kernel")))) {
3534+ unsupported(c, id, "eval of a runtime string is not supported by AOT compilation (define the code statically)");
3535+ return;
3536+ }
35263537 if (recv < 0 && !strcmp(name, "loop") && argc == 0) {
35273538 int blk = nt_ref(nt, id, "block");
35283539 if (blk >= 0) {