# 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

# Brain-flak

Error at character 33: Unclosed '(' character.

Try it online!

[1 of 1] Compiling Main             ( .code.tio.hs, .code.tio.o )

.code.tio.hs:1:4: error: parse error on input ‘of’
|
1 | [1 of 1] Compiling Main             ( .code.tio.hs, .code.tio.o )
|    ^^
/srv/wrappers/haskell: line 5: ./.bin.tio: No such file or directory


Try it online!

# Stack Cats

Error: invalid character in source code, E | E ,edoc ecruos ni retcarahc dilavni :rorrE

Try it online!

# Taxi

error: parse error: likely incomplete statement

Try it online!

/opt/hspal/hspal.rb:69:in run': Illegal opcode: 170  (RuntimeError)
from /opt/hspal/hspal.rb:75:in <main>'


Try it online!

# Quarterstaff

Traceback (most recent call last):
File "/opt/quarterstaff/quarterstaff.py", line 142, in <module>
File "/opt/quarterstaff/quarterstaff.py", line 7, in __init__
self.run(self.parse(program), {}, 0)
File "/opt/quarterstaff/quarterstaff.py", line 35, in parse
raise Exception
Exception


Try it online!

# Haxe

Main.hx:1: characters 0-4 : Unexpected Main


Try it online!

# Hasm

Error with instruction <internal{PARSE}> on line 0:
Syntax error or illegal instruction: Error with instruction <internal{PARSE}> on line 0:
Dumping core:

STACK:

OFFSTACK:

HEAP:
0


Try it online!

# Mornington Crescent

Traceback (most recent call last):
File "/opt/mornington-crescent/esoterpret.py", line 123, in <module>
arguments.stdin, extra)
File "/opt/mornington-crescent/esoterpret.py", line 41, in use_language
while not(interpreter.has_execution_finished()):
File "/opt/mornington-crescent/modules/morningtoncrescent/morningtoncrescent.py", line 50, in has_execution_finished
raise RuntimeError("You have to end at Mornington Crescent.")
RuntimeError: You have to end at Mornington Crescent.


Try it online!

# Muriel

*** ERROR: muriel: Unknown token '*'

Try it online!

Just picked some random esolangs from TIO and keyboard hashed until I got an error, then copy + pasted.

# 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.

# Pxem (pxemi.2.min.posixism), Filename: 14 bytes + Content: 0 bytes = 14 bytes.

• Filename (has trailing LF!): .a B4 .[wxyz]`
• Content: empty.

Try it online!