Error quine
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:
- Run any invalid program.
- Feed the error to the interpreter.
- Repeat step 2 until the error provided and outputted are the same.
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 [.
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 /)
Lua
syntax error near 'error'
Python
File "file.py", line 1
File "file.py", line 1
^
IndentationError: unexpected indent
Replace file.py with the program file name
External resources
- error quine challenge on codegolf stackexchange.