Make an error quine!

104

14

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.

nneonneo

Posted 2014-08-16T07:11:03.277

Reputation: 11 445

1I 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 – 2015-06-01T12:57:51.880

2Ha, 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 – 2017-04-10T06:32:29.527

2When 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 – 2017-05-07T21:50:51.480

1@SteveBennett Why haven't you made that challenge yet? – CalculatorFeline – 2017-05-28T01:53:04.973

1

It's non-observable whether something is output by the runtime or the program. You could argue that a syntacticly invalid program is actually triggering a built-in function that prints an error message, making rule 4 impossible to fulfill. Is this a valid submission in Python 3?

– Esolanging Fruit – 2017-05-28T05:55:49.880

I wonder if we can do the same but with warnings instead of errors... – G. Sliepen – 2019-08-23T19:15:16.747

7What 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 – 2014-08-16T09:24:53.790

Answers

117

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.

Ian D. Scott

Posted 2014-08-16T07:11:03.277

Reputation: 1 841

@IsiahMeadows Quinine? – dkudriavtsev – 2017-05-07T03:55:50.813

2@Mendeleev *Quine (Until somewhat recently, I've constantly misread "quine" as "quinine" for some reason...) – Isiah Meadows – 2017-06-20T12:47:08.283

13I 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. :/ – Ingo Bürk – 2014-08-16T16:24:54.517

24@IngoBürk Fortunately this is a popularity contest, not a golf. – fluffy – 2014-08-16T20:11:53.860

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). – Isiah Meadows – 2014-08-17T08:28:20.857

6@IngoBürk Many real-life problems are about cleverly choosing the language, too. :P – Display Name – 2014-08-18T14:32:16.830

@fluffy Wow, I completely missed that. :) I take back everything I said. – Ingo Bürk – 2014-08-18T14:55:11.077

120

Windows Command Prompt

& was unexpected at this time.

enter image description here

Danko Durbić

Posted 2014-08-16T07:11:03.277

Reputation: 10 241

Note that this works with | also. – MD XF – 2017-05-07T21:01:59.890

7& was unexpected at this time. +1 – workoverflow – 2017-12-11T10:44:48.227

81

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
});

Martin Ender

Posted 2014-08-16T07:11:03.277

Reputation: 184 808

2defined is by definedition defined. Wha...how...? – CalculatorFeline – 2017-02-24T03:18:40.857

3Undefined is not defined (with a capital U) seems to work lol – Shieru Asakoto – 2018-10-11T01:49:20.207

50

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!

Falko

Posted 2014-08-16T07:11:03.277

Reputation: 5 307

Hey how about this in the python stock IDE, SyntaxError: invalid syntax produces the same thing too :) – Gurupad Mamadapur – 2016-10-11T07:37:48.843

Prefer the second one because that's straight up Python; no IDE/Framework mess. – Nick T – 2016-10-11T18:59:24.980

6As 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. :-) – rink.attendant.6 – 2014-08-16T09:30:46.957

9@rink.attendant.6: That's when our much-valued expert knowledge about software engineering is required. ;) – Falko – 2014-08-16T09:33:13.563

@rink.attendant.6 Or when you are sent off running in circles. Try it in the Excel-VBA immediate window. – Dennis Jaheruddin – 2014-08-18T13:14:15.337

46I did step 1, 2, and 3, but I couldn't do step 4, the perl code was perfectly valid! – rodolphito – 2014-11-20T04:48:46.140

42

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):

MD XF

Posted 2014-08-16T07:11:03.277

Reputation: 11 605

42

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

Cruncher

Posted 2014-08-16T07:11:03.277

Reputation: 2 135

10Please note that the language name is ><>, which is usually pronounced "fish". – Aaron – 2015-08-31T12:54:06.970

1And it's really "Something smells fishy..." – Conor O'Brien – 2015-10-15T02:31:54.577

3@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. – Addison Crump – 2015-10-17T21:47:14.103

1@VTCAKAVSMoACE Ah, thanks. – Conor O'Brien – 2015-10-18T01:31:27.290

Cuz 'fish' is the name of the shell program/language for the 90s!

– Nick T – 2016-10-11T19:01:06.173

38

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! ;)

Falko

Posted 2014-08-16T07:11:03.277

Reputation: 5 307

1Can we even call this a whitespace program? – V. Courtois – 2018-07-26T06:42:02.777

1Is this an interpreter bug? – user253751 – 2019-08-27T01:34:40.187

37

Chicken

Error on line 1: expected 'chicken'

Dennis

Posted 2014-08-16T07:11:03.277

Reputation: 196 637

10What a peculiar language – Albert Renshaw – 2017-04-13T08:36:35.567

1Link to language is dead. – pppery – 2019-08-23T03:26:02.550

@pppery Fixed. I should probably get this on TIO. – Dennis – 2019-08-23T12:00:54.100

29

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

rink.attendant.6

Posted 2014-08-16T07:11:03.277

Reputation: 2 776

In jsc: Exception: SyntaxError: Unexpected identifier 'identifier' :D – clap – 2015-11-02T06:59:16.743

2@ConfusedMr_C That's a wierd token to choke on. – SuperJedi224 – 2015-11-02T13:59:37.267

@SuperJedi224 Yes. At least it works :P – clap – 2015-11-02T15:24:03.310

28

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.

Mark

Posted 2014-08-16T07:11:03.277

Reputation: 2 099

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. – Psychonaut – 2015-10-16T14:53:39.903

@Psychonaut, fixed. – Mark – 2015-10-16T18:23:50.323

5If the parser gets confused and throws a syntax error, doesn't that make it not syntactically valid? – Martin Ender – 2014-08-16T10:16:22.940

4@MartinBüttner, that really depends on which you consider the authority for "valid syntax": the language description, or the language implementation. – Mark – 2014-08-16T10:18:38.187

16I see, so technically is syntactically valid but it's tripping up the parser due to a bug of a particular implementation? – Martin Ender – 2014-08-16T10:22:13.467

6More or less, confounded by the fact that there is only one implementation. – Mark – 2014-08-18T19:16:39.817

28

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.

James

Posted 2014-08-16T07:11:03.277

Reputation: 391

-2 bytes: #REF! – Engineer Toast – 2019-10-04T12:50:52.290

20

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

Ingo Bürk

Posted 2014-08-16T07:11:03.277

Reputation: 2 674

19

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

Volune

Posted 2014-08-16T07:11:03.277

Reputation: 291

18

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.

Magic Octopus Urn

Posted 2014-08-16T07:11:03.277

Reputation: 19 422

10These should be two separate answers. – mbomb007 – 2016-12-22T14:49:08.000

17

ArnoldC

missing IT'S SHOWTIME on first line

Paste the code into this compiler.

Mama Fun Roll

Posted 2014-08-16T07:11:03.277

Reputation: 7 234

33What's funny is that IT'S SHOWTIME is in fact on the first line – Cyoce – 2016-09-27T22:36:27.880

2Should make a PR to fix that :P – Nick T – 2016-10-11T19:11:32.977

13

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.

Mark

Posted 2014-08-16T07:11:03.277

Reputation: 351

12

Julia 0.2.0

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

ERROR: syntax: extra token "token" after end of expression

Martin Ender

Posted 2014-08-16T07:11:03.277

Reputation: 184 808

12

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

njpipeorgan

Posted 2014-08-16T07:11:03.277

Reputation: 2 992

I didn't think it was possible. – ngenisis – 2017-01-06T01:47:20.920

9

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.

Florian F

Posted 2014-08-16T07:11:03.277

Reputation: 591

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. – Florian F – 2017-05-06T23:53:56.180

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. – MD XF – 2017-12-07T04:11:02.890

@MDXF: It works with clang. Here is a link to tio.run, 122 bytes: https://tio.run/##S9ZNzknMS///Xy85PyVVryQzXy/ZyhAIFVKLivKLgFRFQWpySWqKQmZKal5JZlpmapFCfpGCuoY6Fxla4rgMIaoU0lPzUosSgar0/v8HAA

– G. Sliepen – 2019-08-23T19:06:34.497

8

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:

Erik the Outgolfer

Posted 2014-08-16T07:11:03.277

Reputation: 38 134

1The link to the repo is broken. – connectyourcharger – 2019-09-04T23:20:10.853

@connectyourcharger Hm, looks like there's no repo anymore. – Erik the Outgolfer – 2019-09-05T12:37:48.253

Yeah, Google searches yield nothing except for repos for Intercal. – connectyourcharger – 2019-09-05T23:54:55.150

@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). – Erik the Outgolfer – 2019-09-06T10:40:16.917

8

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.

proud haskeller

Posted 2014-08-16T07:11:03.277

Reputation: 5 866

. isn't an operator here. It's part of a qualified name. What version of GHCi is this for? – dfeuer – 2019-03-19T04:10:54.347

@dfeuer yeah, my bad. Feel free to fix it. The ghci version is probably around whatever was out at the time. – proud haskeller – 2019-03-19T05:42:41.550

8

C++ (g++)

The file must be saved as 1.pas.

g++: error: 1.pas: Pascal compiler not installed on this system

jimmy23013

Posted 2014-08-16T07:11:03.277

Reputation: 34 042

4Does it still work if the Pascal compiler is installed in the system? – SuperJedi224 – 2015-11-02T13:58:43.603

@SuperJedi224 At least installing FreePascal doesn't help. I suppose GNU Pascal might be the right Pascal compiler, but I didn't try. – jimmy23013 – 2015-11-02T14:16:41.633

7

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

Howard

Posted 2014-08-16T07:11:03.277

Reputation: 23 109

7

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.

BenjiWiebe

Posted 2014-08-16T07:11:03.277

Reputation: 231

7

Applescript (in Script Editor)

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

enter image description here

Digital Trauma

Posted 2014-08-16T07:11:03.277

Reputation: 64 644

8it's an error? – cat – 2016-05-18T00:32:22.793

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 :) – cat – 2016-05-18T00:44:35.933

1@cat I see. Yep, I never claimed grammatical correctness :) – Digital Trauma – 2016-05-18T01:01:53.587

7

AppleScript

A identifier can’t go after this identifier.

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

identifiers

Addison Crump

Posted 2014-08-16T07:11:03.277

Reputation: 10 763

21it should be an identifier... come on.... – cat – 2016-05-18T00:28:24.653

6

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.

Level River St

Posted 2014-08-16T07:11:03.277

Reputation: 22 049

6

CJam 0.6.2

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

Try it online.

Dennis

Posted 2014-08-16T07:11:03.277

Reputation: 196 637

5

GNU Make 4.1

make: *** No rule to make target 'No', needed by 'make'.  Stop.

This is syntactically valid:

  • Make tries to evaluate the target named make (first target is the default),
  • which depends on the target named No,
  • which it has no rule for.

eush77

Posted 2014-08-16T07:11:03.277

Reputation: 1 280

1But don't ***, 'No', and Stop. contain syntactically invalid tokens? Also, have you noticed that your profile shows a picture of someone rushing but your name is eush77? – MD XF – 2017-06-07T21:30:14.183

1@MDXF Oh, no. *** is a wildcard, 'No' is quoted, and the dot in Stop. is allowed (as in filenames, e.g. Stop.c). You can run make --debug to see for yourself that it proceeds exactly as I described. You can also touch No to see the message change :) – eush77 – 2017-06-07T22:42:40.107

@MDXF I'm sorry, I didn't get the joke about rushing and the first letter of my name. Is it somehow unusual on this site? – eush77 – 2017-06-07T22:48:45.853

Ah, okay. +1 and I didn't mean for it to be a joke; I thought you may have had a typo in your username. My bad. – MD XF – 2017-06-07T22:59:50.967

3@MDXF I never thought about my username this way! No, its origin is totally unrelated to the pic :-) – eush77 – 2017-06-07T23:25:45.003

5

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.

ObsequiousNewt

Posted 2014-08-16T07:11:03.277

Reputation: 836

5

Pepe, 9 bytes

RRRERROR!

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

Explanation:

Like I explained here, 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!

u_ndefined

Posted 2014-08-16T07:11:03.277

Reputation: 1 253

I like the enthusiasm of this error message. – Ørjan Johansen – 2019-01-20T08:19:07.813

5

CoffeeScript

Fails on first error, so it's fairly easy to do:

E:\foo.coffee:1:3: error: unexpected \
E:\foo.coffee:1:3: error: unexpected \
  ^

Demo

E:\>coffee -c foo.coffee
E:\foo.coffee:1:3: error: unexpected \
E:\foo.coffee:1:3: error: unexpected \
  ^

E:\>

rink.attendant.6

Posted 2014-08-16T07:11:03.277

Reputation: 2 776

5

zsh (Linux)

zsh: command not found: zsh:

Should work with some small changes in just about any other shell.

ASCIIThenANSI

Posted 2014-08-16T07:11:03.277

Reputation: 1 935

5

Forth

Try it here

This was surprisingly easy to come up with.

a : error(-13): word not found

mbomb007

Posted 2014-08-16T07:11:03.277

Reputation: 21 944

5

Bash

$ bash: bash:: command not found
bash: bash:: command not found

David Conrad

Posted 2014-08-16T07:11:03.277

Reputation: 1 037

4

ArnoldC, 28 bytes

WHAT THE FUCK DID I DO WRONG

This is the only error message in ArnoldC, though you do have to turn off stack traces.

Rɪᴋᴇʀ

Posted 2014-08-16T07:11:03.277

Reputation: 7 410

4

Pyth

    s_push: parser stack overflow
Traceback (most recent call last):
  File "pyth.py", line 752, in <module>
    exec(code_to_remove_tools + py_code_line, environment)
MemoryError

Try it online!

Nick the coder

Posted 2014-08-16T07:11:03.277

Reputation: 96

4

Malbolge, 32 bytes

invalid character in source file

Try it online!

Weijun Zhou

Posted 2014-08-16T07:11:03.277

Reputation: 3 396

4

Lua

Code:

lua: ERROR.lua:1: function arguments expected near '.'

It seems fairly easy to do with lua. I also modified it to work on ideone.com as:

luac: prog.lua:1: function arguments expected near '.'

Try it.

AndoDaan

Posted 2014-08-16T07:11:03.277

Reputation: 2 232

Yeah, got it in few iterations starting from single local. Won't you mind if I'll explain this in answer's body? – val says Reinstate Monica – 2019-07-19T17:51:51.363

4

Rebol

Interestingly, the error message here parses as symbols/tokens:

x
** Script error: x has no value
** Where: do either either either -apply-
** Near: do intern code

So despite looking error-like, it could be made a valid Rebol program if you gave all the words meanings.

However if you wanted an error at the parse phase vs. a runtime error in the code, the program/error could be:

1A
** Syntax error: invalid "integer" -- "1A"
** Where: to case load either either -apply-
** Near: (line 1) 1A

So given that distinction is possible, you can do fun things if you redefine ** from exponentiation into something else (which I can't think of how to make useful for this particular challenge, given it's a quine.)

(Note: Trying to abuse it for a trick uncovered a peculiarity of what happens when ** (an infix operator) is redefined and then used immediately after. I tried:

**: function [:a :b :c :d :e :f] []
** Syntax error: invalid "integer" -- "1A"
** Where: to case load either either -apply-
** Near: (line 1) 1A

My goal was to override the ** so that it would accept its arguments unevaluated. That way ** Syntax error: invalid "integer" -- "1A" (or whatever) would not attempt to assign invalid to error, but pass the symbols to **. But because ** is infix it attempted to raise the function body to the power of Syntax prior to the completion of the assignment of **:.

It can be remedied by putting any token between the [] and the **. But it helps to remember how your language evaluator works. :-P)

HostileFork says dont trust SE

Posted 2014-08-16T07:11:03.277

Reputation: 2 292

4

R (GUI)

Error: unexpected symbol in "Error: unexpected symbol"

The issue here is replicating the ", which causes the error message to change from unexpected symbol to unexpected string constant. Pretty much any error R throws will have the form Error: <something> in "<bad code>", so you will pretty much always have to contend with the quoting. I tried this several other ways and always ended up falling back here.

shadowtalker

Posted 2014-08-16T07:11:03.277

Reputation: 461

3

SmileBASIC

NEXT without FOR in 0:1

Whenever the pre-run parser encounters a NEXT which isn't paired with a FOR, it produces the error NEXT without FOR in slot:line. Here, the code is in slot 0 and on line 1.

snail_

Posted 2014-08-16T07:11:03.277

Reputation: 1 982

Syntax error in 0:1 is shorter – 12Me21 – 2017-01-24T06:41:41.303

2I had that first, but this is a popularity-contest, so I went with something more creative. – snail_ – 2017-01-24T12:08:54.260

3

(t)csh

Unmatched '.

The trailing newline is needed to produce an exact match. Run it with csh quine.csh (or just type it into the shell, that works too).

felixphew

Posted 2014-08-16T07:11:03.277

Reputation: 321

3

Javascript (Chrome/V8), 65 41 39 Bytes

Uncaught =u=_=>{throw`=u=${u};u()`};u()

Try it online!

Sasha

Posted 2014-08-16T07:11:03.277

Reputation: 431

3

Rust, 323 166 164 bytes

Call your program a. and use rustc a..

error: unknown start of token: \
 --> a.:1:32
  |
1 | error: unknown start of token: \
  |                                ^

error: aborting due to previous error

Konrad Borowski

Posted 2014-08-16T07:11:03.277

Reputation: 11 185

3

Python 3, 28 bytes

SyntaxError: invalid syntax

Dat

Posted 2014-08-16T07:11:03.277

Reputation: 879

3

Go

Another fairly easy one using the "general approach" provided in the other answer. I still like my JavaScript ones better.

can't load package: package : 
prog.go:1:1: expected 'package', found 'IDENT' can
prog.go:2:2: invalid package name _

Try it.

rink.attendant.6

Posted 2014-08-16T07:11:03.277

Reputation: 2 776

3

Lua (console), 35 bytes

This is what you get in the Lua console with the usual iterative approach:

stdin:1: '<name>' expected near '1'

which is a bit shorter than the one obtained for putting the code in a file.

Martin Ender

Posted 2014-08-16T07:11:03.277

Reputation: 184 808

3

ksh

$ ksh: ksh::  not found.
ksh: ksh::  not found.

DarkAjax

Posted 2014-08-16T07:11:03.277

Reputation: 669

@shelvacu on my build of bash, bash: command not found errors with bash:: command not found, which errors with bash::: command not found. Am I doing something wrong? – clap – 2015-11-02T15:25:57.823

@ConfusedMr_C must be a case of different versions. I am running 4.3.042-3 on x64 Arch Linux, and it works. – Shelvacu – 2015-11-03T05:42:12.950

@shelvacu I'm running x64 Ubuntu, with whatever version of bash came with Ubuntu 14.04.3. Also, you can do zsh: command not found: zsh: in zsh. – clap – 2015-11-03T23:41:28.917

@shelvacu Sorry, I just found out, I'm using 4.3.11(1)-release on x64 Ubuntu 14.04.3. – clap – 2015-11-06T07:21:08.600

@DarkAjax ksh version 93u+ returns ksh: ksh::: not found. – clap – 2015-11-06T07:24:33.723

@VoteToSpam You are probably running bash in a repl. You can get the right message using bash -c 'bash: bash:: ...'. – jimmy23013 – 2017-05-07T17:42:09.197

4Also works with bash: bash: bash:: comand not found – Shelvacu – 2014-08-20T00:54:07.757

3

Perl

syntax error at quine.pl line 2, at EOF
Execution of quine.pl aborted due to compilation errors.

Replace quine.pl with whatever you named the file and enjoy.

ASCIIThenANSI

Posted 2014-08-16T07:11:03.277

Reputation: 1 935

2Is it even possible to have a syntax error in perl? From what I've read online (mainly here) it seems as though perl accepts anything? – None – 2017-01-28T00:27:43.400

3

Java, in Eclipse

Syntax error on tokens, delete these tokens

aditsu quit because SE is EVIL

Posted 2014-08-16T07:11:03.277

Reputation: 22 326

2

Processing IDE

Probably the friendliest error message I've ever seen.

Syntax error, maybe a missing semicolon?

Result

doodoood

Technically this is cheating a bit because the pane below it prints expected SEMI, found 'error'. Unfortunately the word error is written in single quotes, so trying to copy that into the source of the program causes it to spit out a massive "Badly formed character constant" error... which does not include any singly-quoted words allowing for it to quine itself.

quat

Posted 2014-08-16T07:11:03.277

Reputation: 1 211

2

MATLAB, 66 bytes

Undefined function 'Undefined' for input arguments of type 'char'.

This outputs the same to STDERR (shown in the console in red):

enter image description here

This is actually pretty unknown functionality (and it's rarely useful), which is why the MATLAB submission in the "Hello World!"-challenge may be improved.

This works because MATLAB will automatically interpret a command on the form <word_1 word_2 word_3 word_4>, with no surrounding brackets, as a function on the form:

word_1('word_2')`

That is, it calls a function word_1 and gives the single input argument after the first, and in front of the second space as a string input to that function.

"Real life"-examples that can be used for golfing:

disp Hello   % Shorter than disp('Hello')
Hello

disp Hello World!
Hello

nnz variable
ans =
     8

Note that it will always interpret it as a string, it will not evaluate it:

variable = 3;
nnz variable
ans =
     8
nnz(variable)
ans =
     1

Stewie Griffin

Posted 2014-08-16T07:11:03.277

Reputation: 43 471

In my current MATLAB version (R2016b), this can be considerably shortened to 43 bytes: Undefined function or variable 'Undefined'.. – Sanchises – 2017-06-13T09:20:33.467

Really, it doesn't treat the words after Undefined as string inputs? What happens if you do Undefined('function','or','variable')? In previous versions these commands are equivalent. It doesn't tell you that the character input is invalid? It makes sense, but it's definitely new behavior. What about a=2;b={};a(b). Or just a({1}) without initializing anything first? – Stewie Griffin – 2017-06-13T09:26:40.203

It does, hence "function or variable". However, I think the old error message was misleading, because 'Undefined' does not have to be a function, but could indeed be a variable, and many (most) functions are defined for arbitrary input, seeing as there is no native way that I know of to define a function like y=f(uint32 x), so saying that a function is not defined for 'char' does not make sense. – Sanchises – 2017-06-13T09:36:25.803

As for your examples: Undefined('function','or','variable') returns Undefined function or variable 'Undefined'. (indeed, you could be indexing into the variable Undefined); the latter two examples give Function 'subsindex' is not defined for values of class 'cell'. – Sanchises – 2017-06-13T09:38:10.990

I agree, the new behavior makes more sense than the old one... I'm just surprised that they changed it. It makes this slightly outdated.

– Stewie Griffin – 2017-06-13T10:01:37.870

I don't have the new MATLAB version so I can't test it and create a screenshot myself. Feel free to add it as a separate answer if you like :) – Stewie Griffin – 2017-06-13T10:02:23.233

Well, this is officially a popcon and it reduces a somewhat interesting error quine to the most basic one possible, so I won't post a new one. And yes, your Q&A should now include an 'up to' version number (although I don't feel like combing through the changelogs to see when they changed it). – Sanchises – 2017-06-13T10:16:01.300

2

A Pear Tree

a partridge

Try it online!

Almost every program (that isn't very long) prints a partridge in A Pear Tree.

One of the goals of the language was to be good at challenges; as such, it tries to find a substring of the program that has a very specific property that rarely occurs by chance, and starts running the program there. If it can't find an appropriate entry point, it prints an error. The actual text of the error message was chosen for the The Twelve Days of Christmas reference. (Actually, the design for the language worked the other way round; the main goal was to have a language which errored out on almost any source code, so that it would make the reference in question, so I set about trying to work out what sort of language design would naturally end up doing that.)

user62131

Posted 2014-08-16T07:11:03.277

Reputation:

2

Cubically, 94 bytes


Notepad: 0

   000
   000
   000
111222333444
111222333444
111222333444
   555
   555
   555

There are newlines at the start and end. (Cubically automatically dumps its memory to STDERR when the program finishes.)

Try it online!

MD XF

Posted 2014-08-16T07:11:03.277

Reputation: 11 605

Technically this isn't an error. so it does not "generate at least one error message" – ASCII-only – 2018-06-13T13:26:40.923

2

TI-83/84 Basic

Simple & for your calculator

ERR:SYNTAX

Timtech

Posted 2014-08-16T07:11:03.277

Reputation: 12 038

12Doesn't work. Even if it did, it would be missing the 1:Quit\n2:Goto. – lirtosiast – 2015-09-01T01:44:08.160

2

Factor

No word named "No" found in current vocabulary search path

Guess what it prints?

No word named "No" found in current vocabulary search path

cat

Posted 2014-08-16T07:11:03.277

Reputation: 4 989

1

ForceLang

Works in the latest version of the reference implementation as of the time this answer was written.

Exception in thread "main" lang.exceptions.IllegalInvocationException: Exception is not a function.
    at lang.ForceLang.parse(ForceLang.java:52)
    at lang.ForceLang.main(ForceLang.java:129)

SuperJedi224

Posted 2014-08-16T07:11:03.277

Reputation: 11 342

1

Python 3.5

Note: the source file should be named "1" for this to work

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

officialaimm

Posted 2014-08-16T07:11:03.277

Reputation: 2 739

1

GW-BASIC (least: 12 bytes)

Syntax error

Inspired by the Commodore 64 BASIC answer. Knocked off 2 bytes because IBM and DOS are better than Commodore :P You can download an emulator for GW-BASIC.

NEXT without FOR

Since GW-BASIC is a line-based language, it only evaluates the first instruction after a newline or colon :. Therefore, it reads NEXT and automatically fails it didn't read a FOR.

Apple ][ BASIC (13 bytes)

?SYNTAX ERROR

Woo, 1 less byte than the Commodore answer because the old Apples could beat a Commodore anyday :P

QBasic (43 bytes)

Parse failed: Syntax error at 1:1: Token(:)

Might be cheating because it only works on the first line.

Applesoft BASIC (69 bytes)

ParseError: Syntax error: Expected line number or separator in line 0

Also only works on the first line...

MD XF

Posted 2014-08-16T07:11:03.277

Reputation: 11 605

1

sed

By using this general approach, I have converged on several sed error quines. This may not work in your sed, in which case, you're using the wrong sed, and therefore would you please acquire necessary, error-quining sed.

Try it online! This version works in TIO, and probably not anywhere else. Open the "Debug" panel to see the error.

<code>sed: 1: test.sed: bad flag in substitute command: 'd'</code> and <code>gsed: file toast.sed line 1: extra characters after command</code>

Where sed is macOS's default sed, and gsed is a GNU sed.

zgrep

Posted 2014-08-16T07:11:03.277

Reputation: 1 291

1

Recursiva, 7 bytes

Error!

Try it online!

officialaimm

Posted 2014-08-16T07:11:03.277

Reputation: 2 739

1

NASM for x86: 45 bytes

e.asm:1: error: parser: instruction expected

Assemble (or attempt to assemble) with nasm e.asm

Just in case:

0:beau@beau-Latitude-E6330:[~/asm/q]$ nasm -v
NASM version 2.12.02 compiled on Feb  5 2017
0:beau@beau-Latitude-E6330:[~/asm/q]$ 

user233009

Posted 2014-08-16T07:11:03.277

Reputation: 389

1

Ly

Error occurred at program index 3, instruction o (zero-indexed, includes comments)
EmptyStackError: cannot pop from an empty stack

Demo (using official compiler)

This program makes use of the o in "Error", the first instruction character in the error message that produces an error. (apparently r does nothing with an empty stack)

When a stack is not empty, o takes the top entry off the selected stack and outputs it as ASCII; EmptyStackError occurs when the selected stack is empty. So when Ly runs into this o, it causes this error, since we haven't given the stack anything yet.

weatherman115

Posted 2014-08-16T07:11:03.277

Reputation: 605

1

VB.Net, 32 Bytes

Create a new, empty project named 'A'. Set the startup object to "Sub Main" (it's a drop-down option). Create a new class called anything. Delete everything from the class and copy/paste the following:

'Sub Main' was not found in 'A'.

This works because a single quote is a comment, so it looks like a blank file :D

seadoggie01

Posted 2014-08-16T07:11:03.277

Reputation: 181

aw, couldn't get exact output on TIO – ASCII-only – 2019-01-20T08:46:56.270

1

ESOPUNK, 38 bytes

Invalid instruction INVALID at line 0.

SIGSTACKFAULT

Posted 2014-08-16T07:11:03.277

Reputation: 585

Wasn't this posted after the postdated language consensus was changed? – ASCII-only – 2019-01-20T06:15:10.467

No idea, to be honest. I'm not exactly in the race for anything, though, so I'm not particularly worried. – SIGSTACKFAULT – 2019-01-24T23:37:01.130

1

K (ngn/k), 2 bytes

'c

Try it online!

'c is the response from the console indicating that the variable c is undefined

Thaufeki

Posted 2014-08-16T07:11:03.277

Reputation: 421

Apologies, I've edited, thought what I was getting was STDERR as I was operating in the console and saw the output replicated by oK in TiO – Thaufeki – 2018-10-11T17:29:27.203

1

MiLambda

ERROR_NOHALT

Try it online!

Seems like a short solution

MilkyWay90

Posted 2014-08-16T07:11:03.277

Reputation: 2 264

1

ZSH (macOS), 20 bytes excluding newline

 zsh: bad pattern: ^[

Josh Pritsker

Posted 2014-08-16T07:11:03.277

Reputation: 11

1all error messages should include this: : ^[ – roblogic – 2019-08-23T05:06:39.693

1

Triangularity, 46 bytes

I smell no triangularity. YOU SHALL NOT PASS!

Try it online!

The language requires programs to be in the form of a triangle. If not, it denies you the gate to programming in the world of triangles. It will not let you pass.

MilkyWay90

Posted 2014-08-16T07:11:03.277

Reputation: 2 264

1

Cobra

test.cobra(1): error: Expecting use, assembly, namespace, class, interface or enum, but got "test".
Compilation failed - 1 error, 0 warnings
Not running due to errors above.

Οurous

Posted 2014-08-16T07:11:03.277

Reputation: 7 916

1

Befunge on Wasabi v1.4

There is an interpreter for Befunge called Wasabi, and when an error appears the error message is in the format of a dialog box. This is the program:

Unsupported Command : 'U' at (1, 0). Ignore next syntax error(s)?

To test, download Wasabi v1.4 and insert the above program.

frederick

Posted 2014-08-16T07:11:03.277

Reputation: 349

1

C++

(Using Apple LLVM in Xcode)

Unknown type name 'Unknown'
Expected ';' after top level declarator

Luke

Posted 2014-08-16T07:11:03.277

Reputation: 5 091

1

Loader (using the official Java interpreter):

These should be run from a module named main in order to produce the exact error messages given here.

This works in the most recent version of the interpreter:

Error: Could not evaluate expression Error (module main, line 1)

Explanation:

expression:statement is a conditional. The interpreter doesn't even syntax check the stuff to the right of the colon (if it did, we'd get a different error message) unless the stuff on the left evaluates to a nonzero value. However, as "Error" is an illegal expression, the interpreter can't evaluate it, exiting the program with this error message.

In some earlier interpreter versions, this would work instead:

Exception in thread "main" java.lang.RuntimeException: Could not evaluate expression Exception in thread "main" java.lang.RuntimeException (module main,line 1)
    at Loader.expr(Loader.java:183)
    at Loader.load(Loader.java:201)
    at Loader.main(Loader.java:249)

SuperJedi224

Posted 2014-08-16T07:11:03.277

Reputation: 11 342

1

ChucK

Here's my contribution:

[chuck]:line(1).char(8): syntax error

This works if you first type it into the editor, save it as "chuck", and then run it once. If you run it another time the number in char() goes up by eight.

ChucK can be downloaded here.

The_Basset_Hound

Posted 2014-08-16T07:11:03.277

Reputation: 1 566

1

CJam

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

ev3commander

Posted 2014-08-16T07:11:03.277

Reputation: 1 187

4http://codegolf.stackexchange.com/a/37367 – Dennis – 2016-05-28T02:52:18.420

1

JavaScript

Uncaught SyntaxError: Unexpected identifier

Throws a generic Unexpected identifier error (in Chrome, at least) because it doesn't recognize Uncaught as an identifier.

FinW

Posted 2014-08-16T07:11:03.277

Reputation: 477

I presume that the exact text this generates is not in the standard. Could you please include the browser / JavaScript engine that this submission is "programmed" in? – wizzwizz4 – 2016-10-08T12:57:17.550

It generates "SyntaxError: missing ; before statement" in Firefox. – 12Me21 – 2017-01-25T13:24:59.490

1

Codelike, 36 Bytes

Error at (1,1): Unknown character: E

Try it!

Connor D

Posted 2014-08-16T07:11:03.277

Reputation: 81

1

Ada

test.adb:1:01: compilation unit expected

Really just make an ada file, toss it at the start as above and compile with gcc filename.adb -c.

LambdaBeta

Posted 2014-08-16T07:11:03.277

Reputation: 2 499

0

Go

Try it with this embedded repl.it page:

<script src="//repl.it/embed/Ew1N/0.js"></script>

python-b5

Posted 2014-08-16T07:11:03.277

Reputation: 89

0

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.

CalculatorFeline

Posted 2014-08-16T07:11:03.277

Reputation: 2 608

0

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.

MD XF

Posted 2014-08-16T07:11:03.277

Reputation: 11 605

0

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.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    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
 

Example of it working.

zgrep

Posted 2014-08-16T07:11:03.277

Reputation: 1 291

0

Python 3

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

aaay aaay

Posted 2014-08-16T07:11:03.277

Reputation: 71

The file must be named ".py" for this to work. – aaay aaay – 2017-12-01T19:39:53.863

0

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!

MilkyWay90

Posted 2014-08-16T07:11:03.277

Reputation: 2 264

2The rule about languages postdating the challenge has been abolished, you can compete all you want. – Ørjan Johansen – 2019-03-22T00:51:11.017

@ØrjanJohansen Oh, okay – MilkyWay90 – 2019-03-22T01:04:06.177

0

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.

Sara J

Posted 2014-08-16T07:11:03.277

Reputation: 2 576

0

Snowman, 121 bytes

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

Try it online!

MilkyWay90

Posted 2014-08-16T07:11:03.277

Reputation: 2 264

0

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

MilkyWay90

Posted 2014-08-16T07:11:03.277

Reputation: 2 264

You kinda get screwed by the length of the language name huh? – Jo King – 2019-06-18T02:56:15.543

@JoKing Yeah. It was even shortened on TIO because the name was too long – MilkyWay90 – 2019-06-18T02:58:47.350

0

Pip, 71 bytes

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!

Kenneth Taylor

Posted 2014-08-16T07:11:03.277

Reputation: 183

0

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

TheOnlyMrCat

Posted 2014-08-16T07:11:03.277

Reputation: 1 079

0

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.

user85052

Posted 2014-08-16T07:11:03.277

Reputation:

0

C (tcc), 42 bytes

.code.tio.c:1: error: declaration expected

Try it online!

S.S. Anne

Posted 2014-08-16T07:11:03.277

Reputation: 1 161

0

Piet, using npiet interpreter

cannot read from `Error.txt'; reason: unknown PPM format

Save as 'Error.txt' and put it in the same folder as the npiet executable. If you want to golf, you can of course choose a shorter filename and adjust the code to match.

AlienAtSystem

Posted 2014-08-16T07:11:03.277

Reputation: 488

0

MS SQL (Server version 2012), 64 bytes

Msg 2812, Level 16, State 62, Line 1
Incorrect syntax near '16'.

steenbergh

Posted 2014-08-16T07:11:03.277

Reputation: 7 772

0

CJam, 12 bytes

u not handled

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

username.ak

Posted 2014-08-16T07:11:03.277

Reputation: 411

2http://codegolf.stackexchange.com/a/37367 – Dennis – 2016-05-28T02:51:57.047

0

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!

TuxCrafting

Posted 2014-08-16T07:11:03.277

Reputation: 4 547

Works only if path to interpreter is /opt/straw/straw.rb. (Not that this answer is bad, just to let you know.) – user48538 – 2016-09-15T14:51:03.820

Oh, and also, Try it online! also outputs the timings for the program run and the exit code. – user48538 – 2016-09-15T14:51:59.687

0

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.

David Conrad

Posted 2014-08-16T07:11:03.277

Reputation: 1 037

0

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

David Conrad

Posted 2014-08-16T07:11:03.277

Reputation: 1 037

-2

><>, 25 bytes

something smells fishy...

Try it online!

Explanation

The only error in ><> is something smells fishy....

Sagittarius

Posted 2014-08-16T07:11:03.277

Reputation: 169

Duplicate answer: https://codegolf.stackexchange.com/a/36367/46076

– pppery – 2019-09-03T23:01:48.407