1 A dynamically loaded module whose body raises an exception is not stored in 2 the module table. A later load runs the module again and does not return 3 the incomplete namespace of the failed load. 4 5 -- Testcase -- 6 function run(label, fn) { 7 try { 8 print(label, ": ", fn(), "\n"); 9 } 10 catch (e) { 11 print(label, ": ", e.message, "\n"); 12 } 13 } 14 15 // A named import of a module that the compiler links dynamically reports the 16 // exception of the module, not a missing export. 17 let named = loadstring('import { b } from "failing";\nreturn b;\n', 18 { force_dynlink_list: [ "failing" ] }); 19 20 global.fail = true; 21 run("failed load #1", () => keys(import("failing"))); 22 run("failed load #2", () => keys(import("failing"))); 23 run("failed named import", named); 24 25 global.fail = false; 26 run("good load", () => keys(import("failing"))); 27 run("stored module", () => keys(import("failing"))); 28 run("good named import", named); 29 30 // A statement that only calls import() must not leak in the compiler. 31 import("failing"); 32 -- End -- 33 34 -- File failing.uc -- 35 export const a = 1; 36 37 if (global.fail) 38 die("module body failed"); 39 40 export const b = 2; 41 -- End -- 42 43 -- Args -- 44 -R -L files/ 45 -- End -- 46 47 -- Expect stdout -- 48 failed load #1: module body failed 49 failed load #2: module body failed 50 failed named import: module body failed 51 good load: [ "a", "b" ] 52 stored module: [ "a", "b" ] 53 good named import: 2 54 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt