# Make an error quine!

Your challenge: write a "program", for a language of your choice, that causes the compiler/interpreter/runtime to produce error output when compiling/running your program which is identical to your program's source code.

Rules:

• Your program may be specific to a particular version or implementation of your language's compiler/interpreter/runtime environment. If so, please specify the particulars.
• Only standard compiler/interpreter/runtime options are permitted. You cannot pass some weird flag to your compiler to get a specific result.
• The program does not need to be syntactically or semantically valid, but I may give a bounty to the best syntactically valid submission.
• The program must not produce any output of its own (e.g. by calling a print or output function). All output generated upon attempting to compile/run the program must originate from the compiler/interpreter/runtime.
• The complete output of the compiler/interpreter/runtime must be exactly identical to your program source code.
• The compiler/interpreter/runtime must generate at least one error message when invoked with your program.

This is a popularity contest. Most creative answer, as determined by upvotes, wins. If you can give a good case for using a standard loophole, you may do so.

• What is "error output"? And what does it mean to "generate an error message"? More specifically: 1) Does the output have to be to stderr? 2) If the runtime logs an error to syslog and doesn't write anything to stderr, what should be compared to the source of the program? 3) If the runtime throws an exception internally when given an empty program, but requires a flag to actually print the exception and so ends up exiting with a non-zero exit code but no output, has an error message been generated? – Peter Taylor Aug 16 '14 at 9:24
• I tried doing this in java and got a p3 oscilator. This was the shortest phase: (Compile from q.java): Error: Could not find or load main class Q – SuperJedi224 Jun 1 '15 at 12:57
• Ha, because of a syntactic ambiguity in the first sentence, I thought the challenge here was to produce a program which normally produces no output, but if you pass its own code to it as input, it produces an error. – Steve Bennett Apr 10 '17 at 6:32
• When reporting an error, APL always prints a customizable error name, optionally an error message, the name of the program that caused the error, the (bracketed) line number where the error occurred, the line of code that caused the error, and a line with a caret indicating where parsing stopped. Any hope for participation here? – Adám May 7 '17 at 21:50
• @SteveBennett Why haven't you made that challenge yet? – CalculatorFeline May 28 '17 at 1:53

# CJam, 12 bytes

u not handled


When operator doesn't exist, interpreter prints * not handled

## Straw

/opt/straw/straw.rb:108:in initialize': no implicit conversion of nil into String (TypeError)
from /opt/straw/straw.rb:108:in new'
from /opt/straw/straw.rb:108:in step'
from /opt/straw/straw.rb:225:in run'
from /opt/straw/straw.rb:254:in <main>'


Try It Online!

• Works only if path to interpreter is /opt/straw/straw.rb. (Not that this answer is bad, just to let you know.) – user48538 Sep 15 '16 at 14:51
• Oh, and also, Try it online! also outputs the timings for the program run and the exit code. – user48538 Sep 15 '16 at 14:51

# Elixir

== Compilation error on file e.ex ==
** (SyntaxError) e.ex:3: keyword argument must be followed by space after: ex:
(elixir) lib/kernel/parallel_compiler.ex:114: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1


Put the code in e.ex and compile with elixirc e.ex. There are also some blank lines in the output (and in the file), but I can't get them to appear on here; S.O. eats them.

# F#

e.fs(1,11): error FS0010: Unexpected symbol ':' in implementation file


Compile with fsc --nologo e.fs. Again, there's an extra blank line I can't properly reproduce here. (Without the --nologo flag the compiler wants to announce itself and its version number and display a Microsoft copyright message.)

# Syms, 202 bytes

Traceback (most recent call last):
File "/opt/syms/syms.py", line 196, in <module>
stack.append(("{"+str(stack.pop())+"}").replace("\\","\\\\").replace("&","\\&"))
IndexError: pop from empty list



Try it online! Works on TIO. May not work on your configuration.

# KSH script, 48 bytes

Save as a file named k.

k[1]: not: not found [No such file or directory]


Try it online! Note that TIO saves KSH scripts as .code.tio, so it's a bit longer but still the same thing.

# k, oK

Might as well group these answers together, since it's supposedly the same language. I must say, this general approach is quite versatile.

### oK

Every error seems to have a lot of environment-specific information, because, well, JavaScript is behind it all. Try it online!

/opt/ok/oK.js:876
throw new Error("unexpected character '"+text[0]+"'");
^

Error: unexpected character ')'
at Object.parse (/opt/ok/oK.js:876:8)
at Object.<anonymous> (/opt/ok/repl.js:62:43)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)


### k

Notice the space at the bottom. This works in 2016.06.28 (c) arthur whitney version of kmac.

a
^
value error


Python 3

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

• The file must be named ".py" for this to work. – aaay aaay Dec 1 '17 at 19:39

# ink, 65 bytes

ERROR: 'q' line 1: Empty diverts (->) are only valid on choices



Try it online!

Must be saved in a file called q, which is why the code on TIO is 7 bytes longer.

# Snowman, 121 bytes

SnowmanException thrown at tokenize
what():  at tokenize: letter operator terminated prematurely?
fatal error, aborting


Try it online!

# 33

Very simple. : isn't a valid command, so it's easy to make an unrecognised token error quine. The error is just where the : is in the code.

33 (1:8): Unrecognised token


## GNU Smalltalk REPL

REPL is always acceptable, and I only learned the Smalltalk REPL and don't know how to save programs in a file. (I think TIO does not have Smalltalk yet.)

stdin:1: expected expression


This will work when you start the REPL for the first time.

# Julia 1.0 (Tio)

Implementation specific, but this one is made to run in Tio.

ERROR: LoadError: UndefVarError: syntax: extra token "token" after end of expression
Stacktrace:
[1] include at ./boot.jl:317 [inlined]
[3] include(::Module, ::String) at ./sysimg.jl:29
[4] exec_options(::Base.JLOptions) at ./client.jl:229
[5] _start() at ./client.jl:421
in expression starting at /home/runner/.code.tio:1


Try it online!

# Red 0.6.3

*** Error: not a Red program!


Newline included. Save as a .red file and run with red <filename>.red.

# m4 (before 1.4.18-3 Termux patch), Termux, Android 11, 35 bytes

Who said the error had to be caused directly?

FORTIFY: %n not allowed on Android



Includes trailing newline.

m4 uses a very old version of Gnulib.

Since Android doesn't support %n in printf, Gnulib will replace every printf function in libc with its own custom implementation.

However, stupidly, said function will still use libc's snprintf function internally (which it is supposedly trying to replace because it doesn't work 🤔), and when using it, it attempts to use %n every single time it is called, even if %n isn't in the original format string.

%n used to be silently ignored on Android (similar to macOS), but Android 11 made these errors fatal, causing this error to be printed followed by abort().

I used set +m` to prevent Bash from printing the signal error, and I had to compile from source to undo the -3 patch.

The file itself doesn't matter: m4 is guaranteed to crash no matter what. This includes running with no arguments.

See this Github issue