1 A source file that cannot seek, such as a pipe, is read into a buffer when 2 it is opened: the type test, the interpreter line and the error context all 3 seek in the source. 4 5 -- Testcase -- 6 import { readlink } from 'fs'; 7 8 let ucode = readlink('/proc/self/exe'); 9 10 system(`printf '#!/usr/bin/env ucode\\nprint("script\\\\n");\\nnull.x = 1;\\n' | ${ucode} /dev/stdin 2>&1`); 11 system(`printf 'print("loadfile\\\\n");\\n' | ${ucode} -e 'loadfile("/dev/stdin")();' 2>&1`); 12 system(`printf 'let = 1;\\n' | ${ucode} -e 'try { loadfile("/dev/stdin"); } catch (e) { print(substr(e.message, 0, index(e.message, "\\n")), "\\n"); }' 2>&1`); 13 14 // A precompiled program names its source file for the error context only. 15 // The load of the program must not read a source that cannot seek. 16 let libs = join(" ", map(REQUIRE_SEARCH_PATH, (path) => `-L '${path}'`)); 17 18 system(`${ucode} ${libs} -c -o files/reader.uc /dev/stdin < files/reader-source.uc 2>&1`); 19 system(`echo data | ${ucode} ${libs} files/reader.uc 2>&1`); 20 -- End -- 21 22 -- File reader-source.uc -- 23 import { stdin } from "fs"; 24 25 print("input: ", stdin.read("line")); 26 -- End -- 27 28 -- Args -- 29 -R 30 -- End -- 31 32 -- Expect stdout -- 33 Type error: attempt to set property on null value 34 In /dev/stdin, line 3, byte 10: 35 36 `null.x = 1;` 37 ~~~~~~~~~^~ 38 39 40 script 41 loadfile 42 Unable to compile source file '/dev/stdin': 43 input: data 44 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt