Error quine

From Esolang
Jump to navigation Jump to search

An error quine is a type of quine where the source code is printed as an error.

How to write an error quine

Writing an error quine is much easier than writing a quine, you follow these steps:

  1. Smash random keys on your keyboard.
  2. Feed the error to the interpreter.
  3. Repeat step 1 and 2 until error is the same as input.

Sometimes the program executes correctly, sometimes this process might need to repeat a lot of times (even indefinitely!), but if you're lucky enough, you get an error quine!

Examples

brainfuck (qdb)

unbalanced [.

Python

  File "file.py", line 1
    File "file.py", line 1
    ^
IndentationError: unexpected indent

Replace file.py with the program file name

JavaScript (Node.js)

/path:1
(function (exports, require, module, __filename, __dirname) { /home/runner/.code.tio:1
                                                              ^

SyntaxError: Invalid regular expression flags
    at new Script (vm.js:84:7)
    at createScript (vm.js:264:10)
    at Object.runInThisContext (vm.js:312:10)
    at Module._compile (internal/modules/cjs/loader.js:684:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:342:17)

The file must be store in a UNIX path (i.e.: starts with /)

External resources

See also