125
\$\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
  • 9
    \$\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\$ Commented Aug 16, 2014 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\$ Commented Jun 1, 2015 at 12:57
  • 3
    \$\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\$ Commented Apr 10, 2017 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
    Commented May 7, 2017 at 21:50
  • 1
    \$\begingroup\$ @SteveBennett Why haven't you made that challenge yet? \$\endgroup\$ Commented May 28, 2017 at 1:53

134 Answers 134

1
2 3 4 5
157
\$\begingroup\$

Windows Command Prompt

& was unexpected at this time.

enter image description here

\$\endgroup\$
5
  • 2
    \$\begingroup\$ Note that this works with | also. \$\endgroup\$
    – MD XF
    Commented May 7, 2017 at 21:01
  • 15
    \$\begingroup\$ & was unexpected at this time. +1 \$\endgroup\$ Commented Dec 11, 2017 at 10:44
  • 1
    \$\begingroup\$ Mind blowing one \$\endgroup\$
    – Wasif
    Commented Feb 23, 2021 at 6:27
  • 3
    \$\begingroup\$ Doesn't work for languages other than english :( Sad \$\endgroup\$ Commented Jun 19, 2021 at 15:30
  • 1
    \$\begingroup\$ This should be the winner, not only because it's better than the accepted one IMO, but because it has more upvotes. \$\endgroup\$
    – ophact
    Commented Sep 11, 2021 at 14:39
135
\$\begingroup\$

Ed (1 byte)

All the other solutions thus far are long and ugly. I suppose that is because of the nature of most error messages. But a good error message is elegant in its simplicity. For that, look no further than ed.

?

Save this to a file called edscript and run with ed < edscript, or run ed<<<?. The result:

?

The question mark is written to stderr and ed returns 1, so this actually is an error message. I wonder why ed isn't very popular?

False (0 bytes)

Run with false filename. It writes the program's source code (i.e. nothing) to stderr and returns 1. Of course, calling false a programming language is questionable, and the zero byte quine is unoriginal, but I thought I might as well add it. There is probably some interpreter for a language that prints no error messages, and could replace false.

Now I wish this was code golf.

\$\endgroup\$
7
  • 14
    \$\begingroup\$ I was looking through the (long) list of esolangs to find a language like this. This is the weakness of this challenge. It's not about writing a clever program, it's about cleverly choosing the language. :/ \$\endgroup\$
    – Ingo Bürk
    Commented Aug 16, 2014 at 16:24
  • 27
    \$\begingroup\$ @IngoBürk Fortunately this is a popularity contest, not a golf. \$\endgroup\$
    – fluffy
    Commented Aug 16, 2014 at 20:11
  • \$\begingroup\$ The 0-byte False is also the same code that at one time won the "Worst Abuse of the Rules" award by the IOCCC for making the theoretically shortest quinine. It had plenty of compiler errors, though, and it was written in K&R C, not ISO C (which is stricter). \$\endgroup\$
    – Claudia
    Commented Aug 17, 2014 at 8:28
  • 7
    \$\begingroup\$ @IngoBürk Many real-life problems are about cleverly choosing the language, too. :P \$\endgroup\$ Commented Aug 18, 2014 at 14:32
  • 2
    \$\begingroup\$ @Mendeleev *Quine (Until somewhat recently, I've constantly misread "quine" as "quinine" for some reason...) \$\endgroup\$
    – Claudia
    Commented Jun 20, 2017 at 12:47
88
+100
\$\begingroup\$

CoffeeScript, syntactically valid

As tested on their website using Chrome or Firefox.

ReferenceError: defined is not defined

You can replace defined with anything that's not a built-in variable, but I thought this version was fun. Unfortunately, undefined is not defined in particular doesn't work as a quine.

In CoffeeScript this isn't even a syntax error, because it compiles. This is technically a runtime error in JavaScript, albeit a boring one. CoffeeScript is a likely candidate to produce some more interesting runtime error quines because a lot of funny sentences are valid code. E.g. the above example compiles to

({
  ReferenceError: defined === !defined
});
\$\endgroup\$
2
  • 2
    \$\begingroup\$ defined is by definedition defined. Wha...how...? \$\endgroup\$ Commented Feb 24, 2017 at 3:18
  • 4
    \$\begingroup\$ Undefined is not defined (with a capital U) seems to work lol \$\endgroup\$ Commented Oct 11, 2018 at 1:49
74
\$\begingroup\$

Windows .EXE, 248 bytes

The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.

No, really. Save as quine.txt, then rename to quine.exe (or download it here):

\$\endgroup\$
55
\$\begingroup\$

Python

Spyder

Well, a rather trivial solution for the Spyder IDE is to raise a SyntaxError.

Code and identical output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "/Users/falko/golf.py", line 1
    Traceback (most recent call last):
                         ^
SyntaxError: invalid syntax

(Python 2.7.8 with Spyder 2.2.5)


Terminal

An alternative solution for Python started from command line struggles with an unexpected indent.

Command:

python golf.py

Code and identical output:

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

ideone.com

On ideone.com a solution might be as follows. (Try it!)

Code and identical output:

Traceback (most recent call last):

  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError: SyntaxError: ('invalid syntax', ('prog.py', 1, 22, 'Traceback (most recent call last):\n'))

(This is for Python 2. An example for Python 3 is trivial but with 15 lines of "code" rather lengthy.)


General approach:

How to create your own solution in 2 minutes?

  1. Open a new file in an IDE of your choice.
  2. Bang your head onto the keyboard in front of you.
  3. Compile.
  4. Replace the code with the compiler error message.
  5. Repeat steps 3 and 4 until the code converges.

I bet such a procedure terminates pretty quickly in most cases!

\$\endgroup\$
7
  • 10
    \$\begingroup\$ As you can probably tell, I'm using that general approach. It doesn't work when the copied code progressively increases the amount of compiler errors. :-) \$\endgroup\$ Commented Aug 16, 2014 at 9:30
  • 10
    \$\begingroup\$ @rink.attendant.6: That's when our much-valued expert knowledge about software engineering is required. ;) \$\endgroup\$
    – Falko
    Commented Aug 16, 2014 at 9:33
  • \$\begingroup\$ @rink.attendant.6 Or when you are sent off running in circles. Try it in the Excel-VBA immediate window. \$\endgroup\$ Commented Aug 18, 2014 at 13:14
  • 62
    \$\begingroup\$ I did step 1, 2, and 3, but I couldn't do step 4, the perl code was perfectly valid! \$\endgroup\$
    – vero
    Commented Nov 20, 2014 at 4:48
  • \$\begingroup\$ Hey how about this in the python stock IDE, SyntaxError: invalid syntax produces the same thing too :) \$\endgroup\$ Commented Oct 11, 2016 at 7:37
47
\$\begingroup\$

><> - 25 Bytes

something smells fishy...

In Fish, any bad instruction outputs the error: "something smells fishy...". Since s is not a valid command, it errors immediately.

\$\endgroup\$
5
  • 14
    \$\begingroup\$ Please note that the language name is ><>, which is usually pronounced "fish". \$\endgroup\$
    – Aaron
    Commented Aug 31, 2015 at 12:54
  • 2
    \$\begingroup\$ And it's really "Something smells fishy..." \$\endgroup\$ Commented Oct 15, 2015 at 2:31
  • 3
    \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ On the python interpreter, it is indeed something smells fishy..., but it is Something smells fishy... on the online interpreter. It's dependent on the interpreter. \$\endgroup\$ Commented Oct 17, 2015 at 21:47
  • 1
    \$\begingroup\$ @VTCAKAVSMoACE Ah, thanks. \$\endgroup\$ Commented Oct 18, 2015 at 1:31
  • \$\begingroup\$ Cuz 'fish' is the name of the shell program/language for the 90s! \$\endgroup\$
    – Nick T
    Commented Oct 11, 2016 at 19:01
42
\$\begingroup\$

Chicken

Error on line 1: expected 'chicken'
\$\endgroup\$
4
  • 19
    \$\begingroup\$ What a peculiar language \$\endgroup\$ Commented Apr 13, 2017 at 8:36
  • 1
    \$\begingroup\$ Link to language is dead. \$\endgroup\$ Commented Aug 23, 2019 at 3:26
  • \$\begingroup\$ @pppery Fixed. I should probably get this on TIO. \$\endgroup\$
    – Dennis
    Commented Aug 23, 2019 at 12:00
  • 2
    \$\begingroup\$ waiting for tio addition... \$\endgroup\$
    – Razetime
    Commented Nov 18, 2020 at 8:24
40
\$\begingroup\$

Whitespace

First I thought this is clearly impossible. But actually it is trivial as well. -.-

Fail: Input.hs:108: Non-exhaustive patterns in function parseNum'

Try it.

Yeah, my first whitespace program! ;)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Can we even call this a whitespace program? \$\endgroup\$ Commented Jul 26, 2018 at 6:42
34
\$\begingroup\$

JavaScript

Since different browsers use different JavaScript compilers, they produce different messages. These are, however, rather trivial solutions.

V8 (Chrome 36 / Node.js)

SyntaxError: Unexpected identifier

enter image description here

SpiderMonkey (Firefox 31)

SyntaxError: missing ; before statement

enter image description here

Chakra (Internet Explorer 11)

Expected ';'

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ In jsc: Exception: SyntaxError: Unexpected identifier 'identifier' :D \$\endgroup\$
    – clapp
    Commented Nov 2, 2015 at 6:59
  • 3
    \$\begingroup\$ @ConfusedMr_C That's a wierd token to choke on. \$\endgroup\$ Commented Nov 2, 2015 at 13:59
  • \$\begingroup\$ @SuperJedi224 Yes. At least it works :P \$\endgroup\$
    – clapp
    Commented Nov 2, 2015 at 15:24
  • \$\begingroup\$ Is (f=n=>console.error(`(f=${f})()`))() cheating? \$\endgroup\$
    – emanresu A
    Commented Feb 21, 2021 at 9:31
  • \$\begingroup\$ Spider Monkey! 🐵 \$\endgroup\$ Commented May 13, 2023 at 12:23
34
\$\begingroup\$

Microsoft Excel

Formula: #DIV/0!

Error Message: #DIV/0!

In order to enter a formula without using an equals sign, go into Excel Options/Advanced/Lotus Compatibility Settings and enable Transition Formula Entry.

\$\endgroup\$
1
  • 11
    \$\begingroup\$ -2 bytes: #REF! \$\endgroup\$ Commented Oct 4, 2019 at 12:50
31
\$\begingroup\$

Commodore 64 Basic

?SYNTAX  ERROR

When run on the emulator of your choice (or an actual Commodore 64), produces

?SYNTAX  ERROR

This is, in fact, a syntactically-valid one-line program. The question mark is a shortcut for PRINT, and SYNTAX and ERROR are valid variable names. The error occurs because the parser gets confused by the substring OR in ERROR.

\$\endgroup\$
7
  • 5
    \$\begingroup\$ If the parser gets confused and throws a syntax error, doesn't that make it not syntactically valid? \$\endgroup\$ Commented Aug 16, 2014 at 10:16
  • 6
    \$\begingroup\$ @MartinBüttner, that really depends on which you consider the authority for "valid syntax": the language description, or the language implementation. \$\endgroup\$
    – Mark
    Commented Aug 16, 2014 at 10:18
  • 19
    \$\begingroup\$ I see, so technically is syntactically valid but it's tripping up the parser due to a bug of a particular implementation? \$\endgroup\$ Commented Aug 16, 2014 at 10:22
  • 7
    \$\begingroup\$ More or less, confounded by the fact that there is only one implementation. \$\endgroup\$
    – Mark
    Commented Aug 18, 2014 at 19:16
  • \$\begingroup\$ Nitpick: CBM BASIC actually prints two spaces, not one, between "SYNTAX" and "ERROR". Unfortunately I can't edit this answer to correct it, as Stack Exchange imposes a silly 6-character minimum for edits. \$\endgroup\$
    – Psychonaut
    Commented Oct 16, 2015 at 14:53
23
\$\begingroup\$

Java 8 compilation error quine (12203 bytes)

Generated on windows + mingw with java 1.8.0_11 jdk, using this command:

echo a > Q.java; while true; do javac Q.java 2> Q.err; if [ $(diff Q.err Q.java | wc -c) -eq 0 ]; then break; fi; cat Q.err > Q.java; done

May not be the shortest one, may not be the longest one either, more a proof of concept. Works because error output shows at most 100 errors.

Q.java:1: error: class, interface, or enum expected
Q.java:1: error: class, interface, or enum expected
^
Q.java:1: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:1: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:1: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:2: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:2: error: ';' expected
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:2: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:2: error: = expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:2: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:2: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:2: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:2: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:3: error: illegal start of type
^
^
Q.java:4: error: = expected
Q.java:1: error: <identifier> expected
 ^
Q.java:4: error: <identifier> expected
Q.java:1: error: <identifier> expected
      ^
Q.java:4: error: ';' expected
Q.java:1: error: <identifier> expected
       ^
Q.java:4: error: illegal start of type
Q.java:1: error: <identifier> expected
        ^
Q.java:4: error: = expected
Q.java:1: error: <identifier> expected
               ^
Q.java:5: error: '(' expected
Q.java:1: error: class, interface, or enum expected
 ^
Q.java:5: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:5: error: ';' expected
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:5: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:5: error: = expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:5: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:5: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:5: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:5: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:6: error: illegal start of type
                      ^
                      ^
Q.java:7: error: = expected
Q.java:1: error: <identifier> expected
 ^
Q.java:7: error: <identifier> expected
Q.java:1: error: <identifier> expected
      ^
Q.java:7: error: ';' expected
Q.java:1: error: <identifier> expected
       ^
Q.java:7: error: illegal start of type
Q.java:1: error: <identifier> expected
        ^
Q.java:7: error: = expected
Q.java:1: error: <identifier> expected
               ^
Q.java:8: error: '(' expected
Q.java:1: error: class, interface, or enum expected
 ^
Q.java:8: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:8: error: ';' expected
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:8: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:8: error: = expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:8: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:8: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:8: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:8: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:9: error: illegal start of type
                                 ^
                                 ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
 ^
Q.java:10: error: <identifier> expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
      ^
Q.java:10: error: ';' expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
       ^
Q.java:10: error: illegal start of type
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
        ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
               ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                       ^
Q.java:10: error: illegal start of type
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                               ^
Q.java:10: error: <identifier> expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                ^
Q.java:10: error: unclosed character literal
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                  ^
Q.java:10: error: ';' expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                    ^
Q.java:10: error: unclosed character literal
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                       ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                                     ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                                           ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                                                      ^
Q.java:10: error: = expected
Q.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
                                                                                 ^
Q.java:11: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:11: error: ';' expected
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:11: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:11: error: = expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:11: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:11: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:11: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:11: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:12: error: illegal start of type
                                      ^
                                      ^
Q.java:12: error: <identifier> expected
                                      ^
                                       ^
Q.java:13: error: = expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
   ^
Q.java:13: error: ';' expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
      ^
Q.java:13: error: <identifier> expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
              ^
Q.java:13: error: = expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
               ^
Q.java:13: error: ';' expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
                  ^
Q.java:13: error: = expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
                               ^
Q.java:13: error: unclosed character literal
  (use -source 1.4 or lower to use 'enum' as an identifier)
                                   ^
Q.java:13: error: unclosed character literal
  (use -source 1.4 or lower to use 'enum' as an identifier)
                                        ^
Q.java:13: error: = expected
  (use -source 1.4 or lower to use 'enum' as an identifier)
                                                          ^
Q.java:14: error: <identifier> expected
Q.java:1: error: = expected
      ^
Q.java:14: error: ';' expected
Q.java:1: error: = expected
       ^
Q.java:14: error: illegal start of type
Q.java:1: error: = expected
        ^
Q.java:14: error: = expected
Q.java:1: error: = expected
               ^
Q.java:14: error: illegal start of type
Q.java:1: error: = expected
                 ^
Q.java:15: error: = expected
Q.java:1: error: class, interface, or enum expected
^
Q.java:15: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
 ^
Q.java:15: error: = expected
Q.java:1: error: class, interface, or enum expected
      ^
Q.java:15: error: illegal start of type
Q.java:1: error: class, interface, or enum expected
       ^
Q.java:15: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
        ^
Q.java:15: error: = expected
Q.java:1: error: class, interface, or enum expected
          ^
Q.java:15: error: ';' expected
Q.java:1: error: class, interface, or enum expected
               ^
Q.java:15: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                      ^
Q.java:15: error: <identifier> expected
Q.java:1: error: class, interface, or enum expected
                                 ^
Q.java:15: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier
Q.java:1: error: class, interface, or enum expected
                                      ^
  (use -source 1.4 or lower to use 'enum' as an identifier)
Q.java:15: error: = expected
Q.java:1: error: class, interface, or enum expected
                                           ^
Q.java:16: error: illegal start of type
                                           ^
                                           ^
Q.java:17: error: = expected
Q.java:2: error: <identifier> expected
 ^
Q.java:17: error: <identifier> expected
Q.java:2: error: <identifier> expected
      ^
Q.java:17: error: ';' expected
Q.java:2: error: <identifier> expected
       ^
Q.java:17: error: illegal start of type
Q.java:2: error: <identifier> expected
        ^
Q.java:17: error: = expected
Q.java:2: error: <identifier> expected
               ^
100 errors
\$\endgroup\$
22
\$\begingroup\$

Bash (32)

Save as file named x:

x: line 1: x:: command not found

When run:

>> bash x
x: line 1: x:: command not found
\$\endgroup\$
22
\$\begingroup\$

ArnoldC

missing IT'S SHOWTIME on first line

Paste the code into this compiler.

\$\endgroup\$
2
  • 46
    \$\begingroup\$ What's funny is that IT'S SHOWTIME is in fact on the first line \$\endgroup\$
    – Cyoce
    Commented Sep 27, 2016 at 22:36
  • 3
    \$\begingroup\$ Should make a PR to fix that :P \$\endgroup\$
    – Nick T
    Commented Oct 11, 2016 at 19:11
21
\$\begingroup\$

TrumpScript - Making PPCG Great Again (TrumpScript)

When trying to run this language on a windows PC, the output is always:

Make sure the currently-running OS is not Windows, because we're not PC

So when running this program:

Make sure the currently-running OS is not Windows, because we're not PC

It won't even parse it because the OS check fails, and you get the error message. Examples can be given for Mac as well if anyone wants them haha. God I've wanted to use this in PPCG for awhile now, good that I finally get to.

Full list of errors that can be triggered using environmental specifics:
https://github.com/samshadwell/TrumpScript/blob/master/src/trumpscript/utils.py


Bonus Answer: ArnoldC (ArnoldC)

ArnoldC requires root declaration of IT'S SHOWTIME, meaning main(), so:

WHAT THE FUCK DID I DO WRONG

Results in the only error message in ArnoldC...

WHAT THE FUCK DID I DO WRONG

Which, is actually... hilarious. You have to run it non-verbose though w/o stack traces.

\$\endgroup\$
1
  • 14
    \$\begingroup\$ These should be two separate answers. \$\endgroup\$
    – mbomb007
    Commented Dec 22, 2016 at 14:49
15
\$\begingroup\$

Mathematica

Syntax: "needed." is incomplete; more input is needed.

A . in Mathematica means either a decimal point or function Dot. In this case, the . appears at the end of an expression and cannot be interpreted.


enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ I didn't think it was possible. \$\endgroup\$
    – user61980
    Commented Jan 6, 2017 at 1:47
15
\$\begingroup\$

Z-machine interpreter

I don't know the word "know".

Test against this popular interpreter. Also there's some sort of mostly harmless game hosted there.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Interpreter no longer functions due to lack of Flash support. Link an HTML5 version? \$\endgroup\$
    – Seth
    Commented Oct 6, 2021 at 18:29
  • \$\begingroup\$ Good callout - I've updated the link! \$\endgroup\$
    – Mark
    Commented Oct 7, 2021 at 21:41
  • 1
    \$\begingroup\$ This quine made me laugh simply due to the hitchhikers guide reference :) \$\endgroup\$
    – Seth
    Commented Oct 8, 2021 at 4:05
12
\$\begingroup\$

Julia 0.2.0

Another syntax error found iteratively until a fixed point was reached:

ERROR: syntax: extra token "token" after end of expression
\$\endgroup\$
11
\$\begingroup\$

AppleScript

A identifier can’t go after this identifier.

Both A and identifier can be identifiers, so AppleScript says no.

identifiers

\$\endgroup\$
1
  • 30
    \$\begingroup\$ it should be an identifier... come on.... \$\endgroup\$
    – cat
    Commented May 18, 2016 at 0:28
10
\$\begingroup\$

C++ (g++)

The file must be saved as 1.pas.

g++: error: 1.pas: Pascal compiler not installed on this system
\$\endgroup\$
2
  • 5
    \$\begingroup\$ Does it still work if the Pascal compiler is installed in the system? \$\endgroup\$ Commented Nov 2, 2015 at 13:58
  • \$\begingroup\$ @SuperJedi224 At least installing FreePascal doesn't help. I suppose GNU Pascal might be the right Pascal compiler, but I didn't try. \$\endgroup\$
    – jimmy23013
    Commented Nov 2, 2015 at 14:16
10
\$\begingroup\$

INTERCALL, 90 bytes

Fatal error: A INTERCALL program must start with the mandatory header to prevent golfing.\n

Includes a trailing newline at the end. Note that this isn't STDERR, but it was considered to be error output by many, so I posted it here.

This is the "mandatory header":

INTERCALL IS A ANTIGOLFING LANGUAGE
SO THIS HEADER IS HERE TO PREVENT GOLFING IN INTERCALL
THE PROGRAM STARTS HERE:
\$\endgroup\$
4
  • 3
    \$\begingroup\$ The link to the repo is broken. \$\endgroup\$
    – moltarze
    Commented Sep 4, 2019 at 23:20
  • 1
    \$\begingroup\$ @connectyourcharger Hm, looks like there's no repo anymore. \$\endgroup\$ Commented Sep 5, 2019 at 12:37
  • 1
    \$\begingroup\$ Yeah, Google searches yield nothing except for repos for Intercal. \$\endgroup\$
    – moltarze
    Commented Sep 5, 2019 at 23:54
  • 3
    \$\begingroup\$ @connectyourcharger No need to; there are only 8 repos called "intercall" (case-insensitive), and none of them are about the language, so it's safe to say it's gone for good (no, there's nothing in the Wayback Machine either). \$\endgroup\$ Commented Sep 6, 2019 at 10:40
10
\$\begingroup\$

Pepe, 9 bytes

RRRERROR!

Link to interpreter (paste the code above, permalink removes the ! and O)

Explanation:

The interpreter ignores characters other than R,r,E,e so the code is:

RRRERRR

Now to explain:

  RE    # Push 0
RR      # (RR flag: doesn't exist)
    RRR # There is no command RRR, so output RRRERROR!
\$\endgroup\$
1
  • 2
    \$\begingroup\$ I like the enthusiasm of this error message. \$\endgroup\$ Commented Jan 20, 2019 at 8:19
9
\$\begingroup\$

Applescript (in Script Editor)

Syntax Error
A "error" can't go after this identifier.

enter image description here

\$\endgroup\$
3
  • 11
    \$\begingroup\$ it's an error? \$\endgroup\$
    – cat
    Commented May 18, 2016 at 0:32
  • \$\begingroup\$ The article "A" appears before words which start with a consonant or a consonant sound. For words which begin with a vowel or a vowel sound, the correct article is "an". I'm just being nitpicky :) \$\endgroup\$
    – cat
    Commented May 18, 2016 at 0:44
  • 1
    \$\begingroup\$ @cat I see. Yep, I never claimed grammatical correctness :) \$\endgroup\$ Commented May 18, 2016 at 1:01
9
\$\begingroup\$

C

I applied the method of repeatedly copying the error messages to the source. It converged in 2 cycles. Compiled on OSX 10.9 with 'cc -c error.c'.

error.c:1:1: error: unknown type name 'error'
error.c:1:1: error: unknown type name 'error'
^
error.c:1:6: error: expected identifier or '('
error.c:1:1: error: unknown type name 'error'
     ^
2 errors generated.

Note: This is not so much an answer as it is a methodology to get one. The result might change depending on your OS or the version of cc you are using.

The exact method to get the result is to execute the instructions

$ cc -c error.c 2>out ; mv out error.c ; cat error.c

repeatedly until the output stops changing.

\$\endgroup\$
4
  • \$\begingroup\$ I retried. It didn't work at first. To make it work you have to execute cc -c error.c 2>out and then mv out error.c. And with the version of cc I have today it takes a few more iterations. \$\endgroup\$
    – Florian F
    Commented May 6, 2017 at 23:53
  • \$\begingroup\$ You may want to note that in your answer, that it requires a specific version of OSX cc; otherwise it is invalid and must be deleted per community guidelines. \$\endgroup\$
    – MD XF
    Commented Dec 7, 2017 at 4:11
  • \$\begingroup\$ @MDXF: It works with clang. Here is a link to tio.run, 122 bytes: tio.run/##S9ZNzknMS///Xy85PyVVryQzXy/… \$\endgroup\$
    – G. Sliepen
    Commented Aug 23, 2019 at 19:06
  • \$\begingroup\$ You get a nice long one with gcc -v -Wall -pedantic but it still converges quickly e.g. error.c:1:1: error: unknown type name 'Apple' Apple clang version 11.0.3 (clang-1103.0.32.62) \$\endgroup\$
    – BaseZen
    Commented Nov 18, 2020 at 6:36
8
\$\begingroup\$

BBC Basic, 7 bytes (or 0 Bytes)

This is a valid 7 byte entry:

Mistake

This is the error message produced by the interpreter when it is completely unable to make sense of the code.

On the other hand, this is not:

ERROR

This is a valid keyword in BBC Basic which is supposed to deliberately introduce an error of a specified code into the program, but the syntax is wrong (no code is given.) Therefore it returns Syntax error (which in turn returns Mistake when it is run.)

In general the procedure described by Falko in his answer leads to Mistake in BBC basic. There are a few exceptions. anything producing the errorsDATA not LOCAL or ON ERROR not LOCAL leads to the famous zero byte quine: an empty source code produces an empty file.

Given that most error messages in BBC basic are lowercase (and therefore not valid keywords) I am pretty sure that any invalid input will ultimately lead to one of these possibilities.

\$\endgroup\$
8
\$\begingroup\$

GHCi (a Haskell interpreter/shell)

Code.hs:1:1: Parse error: naked expression at top level

Usage:

Write the code in a file named Code and load with GHCi.

A nice fact is that, if the words were actual identifiers, this would be a legal expression (as long as it would typecheck). This is basically due to the fact that : is a built in operator, . is used for module-qualified names, and whitespace is used to denote function application.

\$\endgroup\$
2
  • \$\begingroup\$ . isn't an operator here. It's part of a qualified name. What version of GHCi is this for? \$\endgroup\$
    – dfeuer
    Commented Mar 19, 2019 at 4:10
  • \$\begingroup\$ @dfeuer yeah, my bad. Feel free to fix it. The ghci version is probably around whatever was out at the time. \$\endgroup\$ Commented Mar 19, 2019 at 5:42
7
\$\begingroup\$

Ruby 2 on Windows

Code:

error.rb:1: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
error.rb:1: syntax error, unexpected tI...
          ^

The code was found by testing and iterating the process over and over until a fix-point was reached. The code must be inside the file "error.rb".

Demo:

C:\>type error.rb
error.rb:1: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTR
ING_DBEG or tSTRING_DVAR or tSTRING_END
error.rb:1: syntax error, unexpected tI...
          ^

C:\>ruby.exe error.rb
error.rb:1: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTR
ING_DBEG or tSTRING_DVAR or tSTRING_END
error.rb:1: syntax error, unexpected tI...
          ^
\$\endgroup\$
7
\$\begingroup\$

CJam 0.6.2

Syntax error:
java.lang.RuntimeException: y not handled

Try it online.

\$\endgroup\$
7
\$\begingroup\$

x86 assembly

Bytecode:

53 65 67 6d 65 6e 74 61 75 69 6f 6e 20 66 61 75
6c 74 20 28 63 6f 72 65 20 64 75 6d 70 65 64 29

i.e. the text

Segmentation fault (core dumped)

Crashes immediately because the second instruction (the first being just "push %[er]bx") is

insl (%dx), %gs:(%di)

which fails because (a) ins cannot take segment overrides, (b) %dx and %di are almost certainly uninitialized, (c) %di is a 16-bit memory address and therefore can't be accessed in long mode, (d) ins is an invalid instruction outside of real mode.

The exact output may vary depending on what system this is run on, but it is likely that it will contain some form of illegal instruction.

\$\endgroup\$
1
  • \$\begingroup\$ To be precise, the text Segmentation fault (core dumped) is generated by your shell. If you set +m before running your program, you won’t see anything. \$\endgroup\$ Commented Oct 29, 2022 at 9:14
7
\$\begingroup\$

C (gcc)

error.c:1:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
 error.c:1:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
      ^
compilation terminated due to -Wfatal-errors.

Compile with gcc -Wfatal-errors error.c.

\$\endgroup\$
1
2 3 4 5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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