101
\$\begingroup\$

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.

\$\endgroup\$
  • 7
    \$\begingroup\$ 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? \$\endgroup\$ – Peter Taylor Aug 16 '14 at 9:24
  • 1
    \$\begingroup\$ 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 \$\endgroup\$ – SuperJedi224 Jun 1 '15 at 12:57
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Steve Bennett Apr 10 '17 at 6:32
  • 2
    \$\begingroup\$ 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? \$\endgroup\$ – Adám May 7 '17 at 21:50
  • 1
    \$\begingroup\$ @SteveBennett Why haven't you made that challenge yet? \$\endgroup\$ – CalculatorFeline May 28 '17 at 1:53

97 Answers 97

0
\$\begingroup\$

Python 3

  File ".py", line 1
    File ".py", line 1
    ^
IndentationError: unexpected indent
\$\endgroup\$
  • \$\begingroup\$ The file must be named ".py" for this to work. \$\endgroup\$ – aaay aaay Dec 1 '17 at 19:39
0
\$\begingroup\$

Turing Machine But Way Worse, 258 bytes

Traceback (most recent call last):
  File "/opt/tmbww/TuringMachineButWayWorse.py", line 16, in <module>
    i[0], i[2], i[3], i[5], i[6] =  int(i[0]), int(i[2]), int(i[3]), int(i[5]), int(i[6])
ValueError: invalid literal for int() with base 10: 'Traceback'

Try it online!

\$\endgroup\$
  • 2
    \$\begingroup\$ The rule about languages postdating the challenge has been abolished, you can compete all you want. \$\endgroup\$ – Ørjan Johansen Mar 22 at 0:51
  • \$\begingroup\$ @ØrjanJohansen Oh, okay \$\endgroup\$ – MilkyWay90 Mar 22 at 1:04
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

Snowman, 121 bytes

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

Try it online!

\$\endgroup\$
0
\$\begingroup\$

W.Y.A.L.H.E.I.N., 253 bytes

Traceback (most recent call last):
  File "/opt/wyalhein/whenyouaccidentallylose100endorsementsinnationstates.py", line 6, in <module>
    seed = int(contents[0])
ValueError: invalid literal for int() with base 10: 'Traceback (most recent call last):\n'

Try it online!

whenyouaccidentallyloseahundredendorsementsinnationstates expects a seed on the first line, and Traceback (most recent call last): is not a valid number (unless we're talking in base 96, of course, but whenyouaccidentallyloseahundredendorsementsinnationstates doesn't).

\$\endgroup\$
  • \$\begingroup\$ You kinda get screwed by the length of the language name huh? \$\endgroup\$ – Jo King Jun 18 at 2:56
  • \$\begingroup\$ @JoKing Yeah. It was even shortened on TIO because the name was too long \$\endgroup\$ – MilkyWay90 Jun 18 at 2:58
0
\$\begingroup\$

Pip running on TIO

code and error:

R is not a unary operator
Fatal error while parsing, execution aborted.

also:

Hit end of tokens while parsing expression
Fatal error while parsing, execution aborted.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

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
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.